NAME
pthread_attr_get_np – get attributes of an existing thread
LIBRARY
POSIX Threads Library (libpthread, -lpthread)
SYNOPSIS
#include <pthread_np.h>
int
pthread_attr_get_np(pthread_t pid, pthread_attr_t *dst);
DESCRIPTION
The pthread_attr_get_np() function is used to retrieve the attributes of the specified thread into an existing pthread_attr_t structure. The attributes' values are the current ones for the target thread, except for the stack top address if not properly aligned for the architecture, since in this case its value has been adjusted internally before use.
Argument dst must be a pointer to a valid attributes object( it was initialized at some point by pthread_attr_init(3) and was not destroyed since then). After a successful call to pthread_attr_get_np(), the individual attributes' values can be retrieved as usual via the corresponding accessor functions as documented in pthread_attr(3). After a failed call to pthread_attr_get_np(), the object pointed to by dst is left unmodified, and can continue to be used as if the failed call never happened.
RETURN VALUES
If successful, pthread_attr_get_np() function returns 0. Otherwise, an error number is returned to indicate the error.
EXAMPLES
This function retrieves the stack size of the thread specified by the pid argument:
size_t
my_thread_stack_size(pthread_t tid)
{
pthread_attr_t attr;
size_t size;
pthread_attr_init(&attr);
pthread_attr_get_np(tid, &attr);
pthread_attr_getstacksize(&attr, &size);
pthread_attr_destroy(&attr);
return (size);
}
ERRORS
The pthread_attr_get_np() function will fail if:
- [EINVAL]
-
One of the arguments has an invalid value.
- [ESRCH]
-
No thread could be found corresponding to that specified by the given thread ID.
- [ENOMEM]
-
There was not enough memory to allocate additional storage needed by the attributes object's implementation.
SEE ALSO
pthread_attr(3), pthread_attr_destroy(3), pthread_attr_getdetachstate(3), pthread_attr_getinheritsched(3), pthread_attr_getschedparam(3), pthread_attr_getschedpolicy(3), pthread_attr_getscope(3), pthread_attr_getstack(3), pthread_attr_getstackaddr(3), pthread_attr_getstacksize(3), pthread_attr_init(3), pthread_np(3)
AUTHORS
The pthread_attr_get_np() function and this manual page were written by Alexey Zelkin ⟨[email protected]⟩, and the latter was revised by Olivier Certner ⟨[email protected]⟩.