Thread creation features (attributes). More...
Thread creation features (attributes).
Definition in file pthread_threading_attr.h.
Go to the source code of this file.
Data Structures | |
struct | pthread_attr_t |
An attribute set to supply to pthread_create() More... | |
struct | sched_param |
This structure is unused right now, and only exists for POSIX compatibility. More... | |
#define | PTHREAD_CREATE_JOINABLE (0) |
Create new pthread as joinable (default). | |
#define | PTHREAD_CREATE_DETACHED (1) |
Create new pthread in detached state. | |
int | pthread_attr_init (pthread_attr_t *attr) |
Initialize attributes for a new pthread. | |
int | pthread_attr_destroy (pthread_attr_t *attr) |
Destroys an attribute set. | |
int | pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) |
Tells whether to create a new pthread in a detached state. | |
int | pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) |
Sets whether to create a new pthread in a detached state. | |
int | pthread_attr_getguardsize (const pthread_attr_t *attr, size_t *guardsize) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_setguardsize (pthread_attr_t *attr, size_t guardsize) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_getschedparam (const pthread_attr_t *attr, struct sched_param *param) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *param) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inherit) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_getscope (const pthread_attr_t *attr, int *scope) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_setscope (pthread_attr_t *attr, int scope) |
This function is unused right now, and only exists for POSIX compatibility. | |
int | pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr) |
Query assigned stack for new pthread. | |
int | pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr) |
Set address of the stack to use for the new pthread. | |
int | pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *stacksize) |
Query set stacksize for new pthread. | |
int | pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) |
Set the stack size for the new pthread. | |
int | pthread_attr_getstack (pthread_attr_t *attr, void **stackaddr, size_t *stacksize) |
Query set stacksize for new pthread. | |
int | pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize) |
Set address and stack size of the stack to use for the new pthread. | |
#define PTHREAD_CREATE_DETACHED (1) |
Create new pthread in detached state.
Definition at line 45 of file pthread_threading_attr.h.
#define PTHREAD_CREATE_JOINABLE (0) |
Create new pthread as joinable (default).
Definition at line 44 of file pthread_threading_attr.h.
int pthread_attr_destroy | ( | pthread_attr_t * | attr | ) |
Destroys an attribute set.
Since pthread_attr_t does not hold dynamic data, this is a no-op.
int pthread_attr_getdetachstate | ( | const pthread_attr_t * | attr, |
int * | detachstate | ||
) |
Tells whether to create a new pthread in a detached state.
[in] | attr | Attribute set to query. |
[out] | detachstate | Either PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. |
int pthread_attr_getguardsize | ( | const pthread_attr_t * | attr, |
size_t * | guardsize | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in] | attr | Unused |
[out] | guardsize | Unused |
int pthread_attr_getinheritsched | ( | const pthread_attr_t * | attr, |
int * | inherit | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in] | attr | Unused |
[out] | inherit | Unused |
int pthread_attr_getschedparam | ( | const pthread_attr_t * | attr, |
struct sched_param * | param | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in] | attr | Unused |
[out] | param | Unused |
int pthread_attr_getschedpolicy | ( | const pthread_attr_t * | attr, |
int * | policy | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in] | attr | Unused |
[out] | policy | Unused |
int pthread_attr_getscope | ( | const pthread_attr_t * | attr, |
int * | scope | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in] | attr | Unused |
[out] | scope | Unused |
int pthread_attr_getstack | ( | pthread_attr_t * | attr, |
void ** | stackaddr, | ||
size_t * | stacksize | ||
) |
Query set stacksize for new pthread.
[in] | attr | Attribute set to query. |
[out] | stackaddr | Pointer to previously assigned stack, or NULL for dynamic allocation. |
[out] | stacksize | Assigned or default stack size, resp. |
int pthread_attr_getstackaddr | ( | const pthread_attr_t * | attr, |
void ** | stackaddr | ||
) |
Query assigned stack for new pthread.
[in] | attr | Attribute set to query |
[out] | stackaddr | Pointer to previously assigned stack, or NULL for dynamic allocation. |
int pthread_attr_getstacksize | ( | const pthread_attr_t * | attr, |
size_t * | stacksize | ||
) |
Query set stacksize for new pthread.
Returns default stack size of the value is yet unset.
[in] | attr | Attribute set to query. |
[out] | stacksize | Assigned or default stack size, resp. |
int pthread_attr_init | ( | pthread_attr_t * | attr | ) |
Initialize attributes for a new pthread.
A zeroed out attr
is initialized.
[in,out] | attr | Structure to initialize |
int pthread_attr_setdetachstate | ( | pthread_attr_t * | attr, |
int | detachstate | ||
) |
Sets whether to create a new pthread in a detached state.
[in,out] | attr | Attribute set to operate on. |
[in] | detachstate | Either PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. |
0
on success. -1
if you managed to supply an illegal value in detachstate
. int pthread_attr_setguardsize | ( | pthread_attr_t * | attr, |
size_t | guardsize | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in,out] | attr | Unused |
[in] | guardsize | Unused |
int pthread_attr_setinheritsched | ( | pthread_attr_t * | attr, |
int | inherit | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in,out] | attr | Unused |
[in] | inherit | Unused |
int pthread_attr_setschedparam | ( | pthread_attr_t * | attr, |
const struct sched_param * | param | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in,out] | attr | Unused |
[in] | param | Unused |
int pthread_attr_setschedpolicy | ( | pthread_attr_t * | attr, |
int | policy | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in,out] | attr | Unused |
[in] | policy | Unused |
int pthread_attr_setscope | ( | pthread_attr_t * | attr, |
int | scope | ||
) |
This function is unused right now, and only exists for POSIX compatibility.
[in,out] | attr | Unused |
[in] | scope | Unused |
int pthread_attr_setstack | ( | pthread_attr_t * | attr, |
void * | stackaddr, | ||
size_t | stacksize | ||
) |
Set address and stack size of the stack to use for the new pthread.
This function requires setting the address as well as the size since only setting the address will make the implementation on some architectures impossible. If *stackaddr == NULL
, then the stack is dynamically allocated with malloc(). No two running threads may operate on the same stack. The stack of a zombie thread (i.e. a non-detached thread that exited but was not yet joined) may in theory be reused even before joining, though there might be problems if the stack was preempted before pthread_exit() completed.
[in,out] | attr | Attribute set to operate on. |
[in] | stackaddr | Static stack to use, or NULL for dynamic allocation. |
[in] | stacksize | Size of the stack of the new thread. Supply 0 to use the default value. |
int pthread_attr_setstackaddr | ( | pthread_attr_t * | attr, |
void * | stackaddr | ||
) |
Set address of the stack to use for the new pthread.
If *stackaddr == NULL
, then the stack is dynamically allocated with malloc(). No two running threads may operate on the same stack. The stack of a zombie thread (i.e. a non-detached thread that exited but was not yet joined) may in theory be reused even before joining, though there might be problems if the stack was preempted before pthread_exit() completed.
[in,out] | attr | Attribute set to operate on. |
[in] | stackaddr | Static stack to use, or NULL for dynamic allocation. |
int pthread_attr_setstacksize | ( | pthread_attr_t * | attr, |
size_t | stacksize | ||
) |
Set the stack size for the new pthread.
If you use pthread_attr_getstackaddr() to assign a static stack, then you must use this function to set the size of the stack. In case of dynamic memory allocation this overrules the default value.
[in,out] | attr | Attribute set to operate on |
[in] | stacksize | Size of the stack of the new thread. Supply 0 to use the default value. |