pthread_attr_getstacksize.......................................................[_POSIX_THREAD_ATTR_STACKSIZE]
int pthread_attr_getstacksize (
const pthread_attr_t *attr, size_t *stacksize);
Determine the size of the stack on which threads created with attr will run.
References: 2, 5.2.3
Headers:
Errors: [EINVAL]attrinvalid.
[ENOSYS] stacksize not supported. Hint: Use on newly created attributes object to find the default stack size.
pthread_attr_init
int pthread_attr_init (
pthread_attr_t *attr);
Initialize a thread attributes object with default attributes.
References: 2, 5.2.3
Headers:
Errors: [ENOMEM] insufficient memory for attr.
Hint: Use to define thread types.
| pthread_aftr_setdetachstate
int pthread_attr_setdetachstate ( pthread_attr_t *attr, int detachstate);
Specify whether threads created with attr will run
detachstate
PTHREAD CREATE JOINABLE
PTHREAD CREATE DETACHED
Thread ID is valid, must be joined.
Thread ID is invalid, cannot be joined, canceled, or modified.
References: 2, 5.2.3
Headers:
Errors: [EINVAL]attrinvalid.
[EINVAL] detachstate invalid. Hint: You can't join or cancel detached threads.
pthread_attr_setstackaddr.....................................................[_POSIX_THREAD_ATTR_STACKADDR]
int pthread_attr_setstackaddr ( pthread_attr_t *attr, void *stackaddr);
Threads created with attr will run on the stack starting at stackaddr. Must be at least PTHREAD_STACK_MIN bytes.
References: 2, 5.2.3
Headers:
Errors: [EINVAL]attrinvalid.
[ENOSYS] stackaddr not supported. Hint: Create only one thread for each stack address, and be careful of
stack alignment.
pthread_attr_setstacksize.......................................................[_POSIX_THREAD_ATTR_STACKSIZE]
int pthread_attr_setstacksize ( pthread_attr_t *attr, size_t stacksize);
Threads created with attr will run on a stack of at least stacksize bytes. Must be at least PTHREAD_STACK_MIN bytes.
References: 2, 5.2.3
[EINVAL] attr or stacksize invalid. [EINVAL] stacksize too small or too big. [ENOSYS] stacksize not supported.
Find the default first (pthread_attr_getstacksize), then increase by multiplying. Use only if a thread needs more than the default.
Headers: Errors:
Hint:
pthread_create
int pthread_create (
pthread_t *tid,
const pthread_attr_t *attr,
void *(*start) (void *),
void *arg);
Create a thread running the start function, essentially an asynchronous call to the function start with argument value arg. The attr argument specifies optional creation attributes, and the identification of the new thread is returned in tid.
References: 2, 5.2.3
Headers:
Errors: [EINVAL] attr invalid.
[EAGAIN] insufficient resources. Hint: All resources needed by thread must already be initialized.
pthread_detach
int pthread_detach (
pthread_t thread);
Detach the thread. Use this to detach the main thread or to "change your mind" after creating a joinable thread in which you are no longer interested.
References: 2, 5.2.3 Headers:
Errors: [EINVAL] thread is not a joinable thread.
[ESRCH] no thread could be found for ID thread. Hint: Detached threads cannot be joined or canceled; storage is freed
immediately on termination.
pthread_equal
int pthread_equal (
pthread_t tl,
pthread_t t2);
Return value 0 if t1 and t2 are equal, otherwise return nonzero.
References: 2, 5.2.3 Headers:
Hint: Compare pthread_self against stored thread identifier.
pthread_exit
int pthread_exit (
void *value_ptr);
Terminate the calling thread, returning the value value_ptr to any joining thread.
References: 2, 5.2.3 Headers:
Hint: value ptr is treated as a value, not the address of a value.
pthread_join
int pthread_join (
pthread_t thread,
void **value_ptr);
Wait for thread to terminate, and return thread's exit value if value_ptr is not NULL. This also detaches thread on successful completion.
References: 2, 5.2.3 Headers:
Errors: [EINVAL] thread is not a joinable thread.
[ESRCH] no thread could be found for ID thread.
[EDEADLK] attempt to join with self. Hint: Detached threads cannot be joined or canceled.
pthread_self
pthread_t pthread_self (void);
Return the calling thread's ID.
References: 2, 5.2.3 Headers:
Hint: Use to set thread's scheduling parameters.
sched_yield
int sched_yield (void);