![]() |
Samsung Internal API reference
2.0
|
Data Structures | |
| struct | __pthread_once_t |
| struct | __pthread_attr_t |
| struct | __pthread_mutex_t |
| struct | __pthread_cond_t |
| struct | __pthread_condattr_t |
Macros | |
| #define | PTHREAD_STACK_MIN (PAGE_SIZE) |
| #define | PTHREAD_GUARD_MIN (PAGE_SIZE) |
| #define | PTHREAD_GUARD_MAX (PAGE_SIZE << 2) |
| #define | MUTEX_STATE_UNLOCKED 0 |
| #define | MUTEX_STATE_LOCKED 1 |
| #define | PTHREAD_MUTEX_INITIALIZER { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_DEFAULT, 0, 0 } |
| #define | PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_ERRORCHECK, 0, 0 } |
| #define | PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_RECURSIVE, 0, 0 } |
| #define | PTHREAD_ONCE_INIT { ATOMIC_INITIALIZER } |
| #define | PTHREAD_COND_INITIALIZER { ATOMIC_INITIALIZER } |
| Object for static initialization of pthread_cond_t variables. | |
| #define | pthread_sigmask(how, set, oldset) sigprocmask(how, set, oldset) |
| Set signal mask for specified thread. More... | |
Typedefs | |
| typedef struct pthread_impl | pthread_impl_t |
| typedef uintptr_t | pthread_t |
| typedef uint32_t | pthread_mutexattr_t |
| typedef struct __pthread_mutex_t | pthread_mutex_t |
| typedef unsigned | pthread_key_t |
| typedef struct __pthread_attr_t | pthread_attr_t |
| typedef struct __pthread_once_t | pthread_once_t |
| typedef struct __pthread_cond_t | pthread_cond_t |
| typedef struct __pthread_cond_t | pthread_condattr_t |
Enumerations | |
| enum | { PTHREAD_MUTEX_NORMAL = 0, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_DESTROYED = -1, PTHREAD_MUTEX_ERRORCHECK_NP = PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_RECURSIVE_NP = PTHREAD_MUTEX_RECURSIVE } |
| types and states for mutex More... | |
| enum | { PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED } |
| detach state attribute settings More... | |
Functions | |
| int | pthread_attr_init (pthread_attr_t *attr) |
| The pthread_attr_init() function initialize attribute struct. More... | |
| int | pthread_attr_destroy (pthread_attr_t *attr) |
| The pthread_attr_destroy() function destroy attribute struct. More... | |
| int | pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *stacksize) |
| The pthread_attr_getstacksize() function gets size of stack. More... | |
| int | pthread_attr_getguardsize (const pthread_attr_t *attr, size_t *guardsize) |
| The pthread_attr_getguardsize() function gets size of guard. More... | |
| int | pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) |
| The pthread_attr_setstacksize() function sets size of stack. More... | |
| int | pthread_attr_setguardsize (pthread_attr_t *attr, size_t guardsize) |
| The pthread_attr_setguardsize() function sets size of guard. More... | |
| int | pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr) |
| The pthread_attr_getstackaddr() function gets stack address. More... | |
| int | pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr) |
| The pthread_attr_setstackaddr() function gets stack address. More... | |
| int | pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr, size_t *stacksize) |
| The pthread_attr_getstack() function gets stack address and size. More... | |
| int | pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize) |
| The pthread_attr_setstack() function sets stack address and size. More... | |
| int | pthread_create (pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) |
The pthread_create() function starts a new thread in the calling process. The new thread starts execution by invoking start_routine() arg is passed as the sole argument of start_routine(). More... | |
| _noreturn_ void | pthread_exit (void *retval) |
| Terminate calling thread. More... | |
| int | pthread_join (pthread_t thread, void **retval) |
Wait for the thread specified by thread to terminate. If that thread has already terminated, then returns immediately. The thread specified by thread must be joinable. More... | |
| int | pthread_once (pthread_once_t *once_control, void(*init_routine)(void)) |
If any thread in a process with a once_control parameter makes a call to pthread_once(), the first call will summon the init_routine(), but subsequent calls will not. The once_control parameter determines whether the associated initialization routine has been called. The init_routine() is complete upon return of pthread_once(). More... | |
| void * | pthread_getspecific (pthread_key_t key) |
Return the value currently bound to the specified key on behalf of the calling thread. More... | |
| int | pthread_setspecific (pthread_key_t key, const void *value) |
Associate a thread-specific value with a key obtained via a previous call to pthread_key_create(). More... | |
| int | pthread_key_create (pthread_key_t *key, void(*destructor)(void *)) |
| Create data key for data manipulation functions (pthread_getspecific(), pthread_setspecific()). Multiple threads can call data manipulation functions with the same key. In this case all threads will have separate data. More... | |
| int | pthread_key_delete (pthread_key_t key) |
Delete data key and destructor associated with key. After key deletion there is no destructor will be called on thread exits. More... | |
| int | pthread_mutexattr_init (pthread_mutexattr_t *attr) |
| Initialize mutex attributes object and initialize attributes with default values. More... | |
| int | pthread_mutexattr_destroy (pthread_mutexattr_t *attr) |
| Destroy attributes object and make all attribute values are uninitialized. More... | |
| int | pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type) |
Get mutex type attribute associated with attr parameter. More... | |
| int | pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type) |
Set mutex type attribute associated with attr parameter. More... | |
| int | pthread_mutex_lock (pthread_mutex_t *mutex) |
| Lock mutex or wait while another thread is unlock currently locked mutex. More... | |
| int | pthread_mutex_trylock (pthread_mutex_t *mutex) |
| Lock mutex or fail if mutex is already locked. More... | |
| int | pthread_mutex_unlock (pthread_mutex_t *mutex) |
| Release lock on currently locked mutex. More... | |
| int | pthread_mutex_destroy (pthread_mutex_t *mutex) |
| Destroy mutex object and make all associated data are uninitialized. More... | |
| int | pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) |
Initialize mutex object mutex with attributes given by attr parameter. If attr parameter is NULL then default attributes will be used. More... | |
| int | pthread_cond_destroy (pthread_cond_t *cond) |
| Destroy conditional variable object and make it unitialized. More... | |
| int | pthread_condattr_init (pthread_condattr_t *attr) |
| Initialize conditional variable attributes with default values. More... | |
| int | pthread_condattr_destroy (pthread_condattr_t *attr) |
| Destroy conditional variable attributes. More... | |
| int | pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) |
Initialize conditional variable object cond with attributes given by attr parameter. More... | |
| int | pthread_cond_signal (pthread_cond_t *cond) |
Unblock at least one of the threads that are blocked on the specified condition variable cond (if any threads are blocked on cond). More... | |
| int | pthread_cond_broadcast (pthread_cond_t *cond) |
Wake up all threads locked by conditional variable cond. More... | |
| int | pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) |
Block on condition variable cond, while another thread will unblock this variable by pthread_cond_broadcast() / pthread_cond_signal() call. More... | |
| int | pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *timeout) |
Block on condition variable cond, while another thread will unblock this variable by pthread_cond_broadcast() / pthread_cond_signal() call. If timeout reached before condition set then wait will be interrupted and error is returned. More... | |
| pthread_t | pthread_self (void) |
| Obtain ID of the calling thread. More... | |
| int | pthread_kill (pthread_t thread, int sig) |
| Send signal to specified thread. More... | |
| int | pthread_equal (pthread_t t1, pthread_t t2) |
| Compare thread IDs. More... | |
| int | pthread_detach (pthread_t thread) |
| Detach a thread. More... | |
| int | pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) |
| Set the detach state attribute. More... | |
| int | pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) |
| Get the detach state attribute. More... | |
| int | pthread_getattr_np (pthread_t thread, pthread_attr_t *attr) |
| Get attributes of created thread. More... | |
| struct __pthread_once_t |
| struct __pthread_attr_t |
| struct __pthread_mutex_t |
Pthread mutex object type.
| Data Fields | ||
|---|---|---|
| unsigned | attr | |
| pthread_t | caller_thread | |
| unsigned | count | |
| atomic_t | state | |
| struct __pthread_cond_t |
| struct __pthread_condattr_t |
Condition variable attributes type. Not implemented
| #define MUTEX_STATE_LOCKED 1 |
#include <pthread.h>
Lock state for mutex.
| #define MUTEX_STATE_UNLOCKED 0 |
#include <pthread.h>
Unlock state for mutex.
| #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_ERRORCHECK, 0, 0 } |
#include <pthread.h>
pthread_mutex_t object for static mutex initialization with errorcheck.
| #define PTHREAD_GUARD_MAX (PAGE_SIZE << 2) |
#include <pthread.h>
Maximum stack guard size.
| #define PTHREAD_GUARD_MIN (PAGE_SIZE) |
#include <pthread.h>
Minimum stack guard size.
| #define PTHREAD_MUTEX_INITIALIZER { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_DEFAULT, 0, 0 } |
#include <pthread.h>
pthread_mutex_t object for static mutex initialization.
| #define PTHREAD_ONCE_INIT { ATOMIC_INITIALIZER } |
#include <pthread.h>
Object for static initialization of pthread_once_t variables.
| #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_RECURSIVE, 0, 0 } |
#include <pthread.h>
pthread_mutex_t object for static recursive mutex initialization.
| #define pthread_sigmask | ( | how, | |
| set, | |||
| oldset | |||
| ) | sigprocmask(how, set, oldset) |
#include <pthread.h>
Set signal mask for specified thread.
| [in] | how | defines how to set mask, must be one of: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK |
| [in] | set | if not NULL, signals mask to act on, otherwise ignored |
| [in] | oldset | if not NULL then here stored previous value of the signal mask |
| 0 | On success. |
| EINVAL | The value specified by how is invalid |
| EFAULT | The set or oldset argument points outside the process's allocated address space |
Example:
| #define PTHREAD_STACK_MIN (PAGE_SIZE) |
#include <pthread.h>
Minimum stack size.
#include <pthread.h>
Type for pthread attibutes.
#include <pthread.h>
Type for pthread conditional variable.
#include <pthread.h>
Type for attibutes of pthread conditional variable.
#include <pthread.h>
Internal pthread info representation.
#include <pthread.h>
Type for unique per-thread keys.
#include <pthread.h>
Pthread mutex type.
#include <pthread.h>
Mutex attibute variable.
#include <pthread.h>
Type for pthreads, created once.
| anonymous enum |
#include <pthread.h>
types and states for mutex
| Enumerator | |
|---|---|
| PTHREAD_MUTEX_NORMAL |
Regular mutex. |
| PTHREAD_MUTEX_RECURSIVE |
Mutex with the concept of a lock count. |
| PTHREAD_MUTEX_ERRORCHECK |
Mutex with error checking. |
| PTHREAD_MUTEX_DEFAULT |
Regular mutex. |
| PTHREAD_MUTEX_DESTROYED |
Mutex state after pthread_mutex_destroy(). |
| PTHREAD_MUTEX_ERRORCHECK_NP |
Same as PTHREAD_MUTEX_ERRORCHECK. |
| PTHREAD_MUTEX_RECURSIVE_NP |
Same as PTHREAD_MUTEX_RECURSIVE. |
| anonymous enum |
#include <pthread.h>
detach state attribute settings
| Enumerator | |
|---|---|
| PTHREAD_CREATE_JOINABLE |
Set thread to be joinable |
| PTHREAD_CREATE_DETACHED |
Set thread to be detached |
| int pthread_attr_destroy | ( | pthread_attr_t * | attr | ) |
#include <pthread.h>
The pthread_attr_destroy() function destroy attribute struct.
| [in] | attr | is attribute struct. |
| 0 | On success. |
| EINVAL | Invalid attr address |
| int pthread_attr_getdetachstate | ( | const pthread_attr_t * | attr, |
| int * | detachstate | ||
| ) |
#include <pthread.h>
Get the detach state attribute.
| [in] | attr | Thread attributes object |
| [out] | detachstate | Buffer to return detach state |
| 0 | On success |
| int pthread_attr_getguardsize | ( | const pthread_attr_t * | attr, |
| size_t * | guardsize | ||
| ) |
#include <pthread.h>
The pthread_attr_getguardsize() function gets size of guard.
| [in] | attr | is attribute struct. |
| [out] | guardsize | is buffer to return size of guard. |
| 0 | On success. |
| int pthread_attr_getstack | ( | const pthread_attr_t * | attr, |
| void ** | stackaddr, | ||
| size_t * | stacksize | ||
| ) |
#include <pthread.h>
The pthread_attr_getstack() function gets stack address and size.
| [in] | attr | is attribute struct. |
| [out] | stackaddr | is buffer to save stack address. |
| [out] | stacksize | is buffer to save stack size. |
| 0 | On success. |
| int pthread_attr_getstackaddr | ( | const pthread_attr_t * | attr, |
| void ** | stackaddr | ||
| ) |
#include <pthread.h>
The pthread_attr_getstackaddr() function gets stack address.
| [in] | attr | is attribute struct. |
| [out] | stackaddr | is buffer to save stack address. |
| 0 | On success. |
| int pthread_attr_getstacksize | ( | const pthread_attr_t * | attr, |
| size_t * | stacksize | ||
| ) |
#include <pthread.h>
The pthread_attr_getstacksize() function gets size of stack.
| [in] | attr | is attribute struct. |
| [out] | stacksize | is buffer to return size of stack. |
| 0 | On success. |
| int pthread_attr_init | ( | pthread_attr_t * | attr | ) |
#include <pthread.h>
The pthread_attr_init() function initialize attribute struct.
| [in] | attr | is attribute struct. |
| 0 | On success. |
| EINVAL | Invalid attr address |
| int pthread_attr_setdetachstate | ( | pthread_attr_t * | attr, |
| int | detachstate | ||
| ) |
| int pthread_attr_setguardsize | ( | pthread_attr_t * | attr, |
| size_t | guardsize | ||
| ) |
#include <pthread.h>
The pthread_attr_setguardsize() function sets size of guard.
| [in] | attr | is attribute struct. |
| [in] | guardsize | is wished size of guard. |
| 0 | On success. |
| EINVAL | size is less than DEFAULT_GUARD_SIZE. |
| int pthread_attr_setstack | ( | pthread_attr_t * | attr, |
| void * | stackaddr, | ||
| size_t | stacksize | ||
| ) |
#include <pthread.h>
The pthread_attr_setstack() function sets stack address and size.
| [in] | attr | is attribute struct. |
| [in] | stackaddr | is buffer to save stack address. |
| [in] | stacksize | is buffer to save stack size. |
| 0 | On success. |
| int pthread_attr_setstackaddr | ( | pthread_attr_t * | attr, |
| void * | stackaddr | ||
| ) |
#include <pthread.h>
The pthread_attr_setstackaddr() function gets stack address.
| [in] | attr | is attribute struct. |
| [in] | stackaddr | is desired stack address. |
| 0 | On success. |
| int pthread_attr_setstacksize | ( | pthread_attr_t * | attr, |
| size_t | stacksize | ||
| ) |
#include <pthread.h>
The pthread_attr_setstacksize() function sets size of stack.
| [in] | attr | is attribute struct. |
| [in] | stacksize | is wished size of stack. |
| 0 | On success. |
| EINVAL | size is less than PTHREAD_STACK_MIN. |
| int pthread_cond_broadcast | ( | pthread_cond_t * | cond | ) |
#include <pthread.h>
Wake up all threads locked by conditional variable cond.
| [out] | cond | A pointer to the pthread_cond_t object for which user wants to unblock the threads. |
| 0 | If successful. |
| EINVAL | The value cond does not refer to an initialized condition variable. |
Example:
| int pthread_cond_destroy | ( | pthread_cond_t * | cond | ) |
#include <pthread.h>
Destroy conditional variable object and make it unitialized.
| [out] | cond | A pointer to the pthread_cond_t object that to destroy. |
| 0 | On success. |
| EBUSY | The implementation has detected an attempt to destroy the object referenced by cond while it is referenced (for example, while being used in a pthread_cond_wait()) by another thread. |
| EINVAL | The value specified by cond is invalid. |
Example:
| int pthread_cond_init | ( | pthread_cond_t * | cond, |
| const pthread_condattr_t * | attr | ||
| ) |
#include <pthread.h>
Initialize conditional variable object cond with attributes given by attr parameter.
| [out] | cond | A pointer to the pthread_cond_t object to initialize. |
| [in] | attr | NULL, or a pointer to a pthread_condattr_t object that specifies the attributes that you want to use for the cond. |
| 0 | On success it returns 0. |
| EAGAIN | The system lacked the necessary resources (other than memory) to initialise another condition variable. |
| ENOMEM | Insufficient memory exists to initialise the condition variable. |
| EBUSY | The implementation has detected an attempt to re-initialise the object referenced by cond, a previously initialised, but not yet destroyed, condition variable. |
| EINVAL | The value specified by attr is invalid. |
Example:
| int pthread_cond_signal | ( | pthread_cond_t * | cond | ) |
#include <pthread.h>
Unblock at least one of the threads that are blocked on the specified condition variable cond (if any threads are blocked on cond).
| [out] | cond | A pointer to the pthread_cond_t object for which user wants to unblock the threads. |
| 0 | If successful. |
| EINVAL | The value cond does not refer to an initialized condition variable. |
Example:
| int pthread_cond_timedwait | ( | pthread_cond_t * | cond, |
| pthread_mutex_t * | mutex, | ||
| const struct timespec * | timeout | ||
| ) |
#include <pthread.h>
Block on condition variable cond, while another thread will unblock this variable by pthread_cond_broadcast() / pthread_cond_signal() call. If timeout reached before condition set then wait will be interrupted and error is returned.
| [out] | cond | A pointer to the pthread_cond_t object that user wants the threads to block on. |
| [out] | mutex | The mutex that to unlock. |
| [out] | timeout | Timeout to wait for condition |
| 0 | On success. |
| EINVAL | The value specified by cond or mutex or timeout is invalid. |
| EINVAL | Different mutexes were supplied for concurrent pthread_cond_wait() operations on the same condition variable. |
| EPERM | The mutex was not owned by the current thread at the time of the call. |
| ETIMEDOUT | The timeout occured while awaiting for condition |
Example:
| int pthread_cond_wait | ( | pthread_cond_t * | cond, |
| pthread_mutex_t * | mutex | ||
| ) |
#include <pthread.h>
Block on condition variable cond, while another thread will unblock this variable by pthread_cond_broadcast() / pthread_cond_signal() call.
| [out] | cond | A pointer to the pthread_cond_t object that user wants the threads to block on. |
| [out] | mutex | The mutex that to unlock. |
| 0 | On success. |
| EINVAL | The value specified by cond or mutex is invalid. |
| EINVAL | Different mutexes were supplied for concurrent pthread_cond_wait() operations on the same condition variable. |
| EPERM | The mutex was not owned by the current thread at the time of the call. |
Example:
| int pthread_condattr_destroy | ( | pthread_condattr_t * | attr | ) |
#include <pthread.h>
Destroy conditional variable attributes.
| [in] | attr | pointer to a pthread_condattr_t object that specifies the attributes that you want to use for the cond. |
| 0 | On success it returns 0. |
| int pthread_condattr_init | ( | pthread_condattr_t * | attr | ) |
#include <pthread.h>
Initialize conditional variable attributes with default values.
| [out] | attr | pointer to a pthread_condattr_t object that specifies the attributes that you want to use for the cond. |
| 0 | On success it returns 0. |
| int pthread_create | ( | pthread_t * | thread, |
| const pthread_attr_t * | attr, | ||
| void *(*)(void *) | start_routine, | ||
| void * | arg | ||
| ) |
#include <pthread.h>
The pthread_create() function starts a new thread in the calling process. The new thread starts execution by invoking start_routine() arg is passed as the sole argument of start_routine().
| [out] | thread | NULL, or a pointer to a pthread_t object where the function can store the thread ID of the new thread. |
| [in] | attr | NULL, a pointer to a pthread_attr_t structure that specifies the attributes of the new thread. |
| [in] | start_routine | The routine where the thread begins, with arg as its only argument. |
| [in] | arg | single parameter of start_routine() function. |
| 0 | On success. |
| EAGAIN | The system lacked the necessary resources to create another thread, or the system-imposed limit on the total number of threads in a process would be exceeded. |
| EPERM | The caller does not have appropriate permission to set the required scheduling parameters or scheduling policy. |
| EINVAL | The attributes specified by attr are invalid. |
Example:
| int pthread_detach | ( | pthread_t | thread | ) |
#include <pthread.h>
Compare thread IDs.
| [in] | t1 | Thread 1 id |
| [in] | t2 | Thread 2 id |
| Nonzero | if two thread IDs are equal |
| 0 | if two thread IDs are not equal |
Example:
| _noreturn_ void pthread_exit | ( | void * | retval | ) |
#include <pthread.h>
Terminate calling thread.
| [in] | retval | value which will be available by pthread_join. |
| int pthread_getattr_np | ( | pthread_t | thread, |
| pthread_attr_t * | attr | ||
| ) |
#include <pthread.h>
Get attributes of created thread.
| [in] | thread | thread to get attributtes from |
| [out] | attr | Buffer to return thread attributes |
| 0 | On success |
| void* pthread_getspecific | ( | pthread_key_t | key | ) |
#include <pthread.h>
Return the value currently bound to the specified key on behalf of the calling thread.
| [in] | key | The key associated with the data that user wants to get. |
Example:
| int pthread_join | ( | pthread_t | thread, |
| void ** | retval | ||
| ) |
#include <pthread.h>
Wait for the thread specified by thread to terminate. If that thread has already terminated, then returns immediately. The thread specified by thread must be joinable.
| [in] | thread | Target thread which termination is waited. |
| [out] | retval | NULL, or a double pointer to a location where the function can store the value passed to pthread_exit() by the target thread. |
| 0 | If successful. |
| EINVAL | The implementation has detected that the value specified by thread does not refer to a joinable thread. |
| ESRCH | No thread could be found corresponding to that specified by the given thread ID. |
| EDEADLK | A deadlock was detected or the value of thread specifies the calling thread. |
Example:
| int pthread_key_create | ( | pthread_key_t * | key, |
| void(*)(void *) | destructor | ||
| ) |
#include <pthread.h>
Create data key for data manipulation functions (pthread_getspecific(), pthread_setspecific()). Multiple threads can call data manipulation functions with the same key. In this case all threads will have separate data.
| [out] | key | A pointer to a pthread_key_t object where the function can store the new key. |
| [in] | destructor | (optional) pointer to function to be called when you destroy the key. |
| 0 | On success. |
| EINVAL | The key value is invalid. |
Example:
| int pthread_key_delete | ( | pthread_key_t | key | ) |
#include <pthread.h>
Delete data key and destructor associated with key. After key deletion there is no destructor will be called on thread exits.
| [in] | key | The key, created by calling pthread_key_create() to delete. |
| 0 | On success. |
| EAGAIN | The system lacked the necessary resources to create another thread-specific data key, or the system-imposed limit on the total number of keys per process { PTHREAD_KEYS_MAX } has been exceeded. |
| ENOMEM | Insufficient memory exists to create the key. |
Example:
| int pthread_kill | ( | pthread_t | thread, |
| int | sig | ||
| ) |
#include <pthread.h>
Send signal to specified thread.
| [in] | thread | thread to send signal |
| [in] | sig | signal id to send |
| 0 | On success. |
| EINVAL | The value specified by sig not a valid signal identifier |
| EPERM | The signal id specified by sig is not allowed to send from unprivileged task |
| ESRCH | Specified thread not found |
Example:
| int pthread_mutex_destroy | ( | pthread_mutex_t * | mutex | ) |
#include <pthread.h>
Destroy mutex object and make all associated data are uninitialized.
| [out] | mutex | A pointer to the pthread_mutex_t object to destroy. |
| 0 | On success. |
| EBUSY | The implementation has detected an attempt to destroy the object referenced by mutex while it is locked or referenced (for example, while being used in a pthread_cond_wait()) by another thread. |
| EINVAL | The value specified by mutex is invalid. |
Example:
| int pthread_mutex_init | ( | pthread_mutex_t * | mutex, |
| const pthread_mutexattr_t * | attr | ||
| ) |
#include <pthread.h>
Initialize mutex object mutex with attributes given by attr parameter. If attr parameter is NULL then default attributes will be used.
| [out] | mutex | A pointer to the pthread_mutex_t object to initialize. |
| [in] | attr | NULL, or a pointer to a pthread_mutexattr_t object that specifies the attributes that you want to use for the mutex. |
| 0 | On success. |
| EAGAIN | The system lacked the necessary resources (other than memory) to initialise another mutex. |
| ENOMEM | Insufficient memory exists to initialise the mutex. |
| EPERM | The caller does not have the privilege to perform the operation |
| EBUSY | The implementation has detected an attempt to re-initialise the object referenced by mutex, a previously initialised, but not yet destroyed, mutex. |
| EINVAL | The value specified by attr is invalid. |
Example:
| int pthread_mutex_lock | ( | pthread_mutex_t * | mutex | ) |
#include <pthread.h>
Lock mutex or wait while another thread is unlock currently locked mutex.
| [out] | mutex | A pointer to the pthread_mutex_t object to lock. |
| 0 | On success. |
| EINVAL | The value specified by mutex does not refer to an initialized mutex object. |
| EAGAIN | The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. |
| EDEADLK | The current thread already owns the mutex. |
Example:
| int pthread_mutex_trylock | ( | pthread_mutex_t * | mutex | ) |
#include <pthread.h>
Lock mutex or fail if mutex is already locked.
| [out] | mutex | A pointer to the pthread_mutex_t object to lock. |
| 0 | On success. |
| EBUSY | The mutex could not be acquired because it was already locked. |
| EINVAL | The value specified by mutex does not refer to an initialized mutex object. |
| EAGAIN | The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. |
Example:
| int pthread_mutex_unlock | ( | pthread_mutex_t * | mutex | ) |
#include <pthread.h>
Release lock on currently locked mutex.
| [out] | mutex | A pointer to the pthread_mutex_t object to unlock. |
| 0 | On success. |
| EPERM | The current thread does not own the mutex. |
Example:
| int pthread_mutexattr_destroy | ( | pthread_mutexattr_t * | attr | ) |
#include <pthread.h>
Destroy attributes object and make all attribute values are uninitialized.
| [in] | attr | A pointer to the pthread_mutexattr_t object that user wants to get the attribute from. |
| 0 | On success. |
| EINVAL | The value specified by attr is invalid. |
Example:
| int pthread_mutexattr_gettype | ( | const pthread_mutexattr_t * | attr, |
| int * | type | ||
| ) |
#include <pthread.h>
Get mutex type attribute associated with attr parameter.
| [in] | attr | A pointer to the pthread_mutexattr_t object to get the attribute from. |
| [out] | type | A pointer to location where the function can store the type. |
| 0 | On success. |
| EINVAL | The value specified by attr is invalid. |
Example:
| int pthread_mutexattr_init | ( | pthread_mutexattr_t * | attr | ) |
#include <pthread.h>
Initialize mutex attributes object and initialize attributes with default values.
| [in] | attr | A pointer to the pthread_mutexattr_t object to initialize. |
| 0 | On success. |
| ENOMEM | Insufficient memory exists to initialize the mutex attributes object. |
Example:
| int pthread_mutexattr_settype | ( | pthread_mutexattr_t * | attr, |
| int | type | ||
| ) |
#include <pthread.h>
Set mutex type attribute associated with attr parameter.
| [out] | attr | A pointer to the pthread_mutexattr_t object to set the attribute in. |
| [in] | type | Parameter type can be one of the following values:
|
| 0 | On success. |
| EINVAL | The value type is invalid. |
| EINVAL | The value specified by attr is invalid. |
Example:
| int pthread_once | ( | pthread_once_t * | once_control, |
| void(*)(void) | init_routine | ||
| ) |
#include <pthread.h>
If any thread in a process with a once_control parameter makes a call to pthread_once(), the first call will summon the init_routine(), but subsequent calls will not. The once_control parameter determines whether the associated initialization routine has been called. The init_routine() is complete upon return of pthread_once().
| [out] | once_control | A pointer to a pthread_once_t object that the function uses to determine whether or not to run the initialization code. |
| [in] | init_routine | The function that new thread will run. |
| 0 | Upon successful completion. |
| EINVAL | The implementation has detected that the value specified by thread does not refer to a joinable thread. |
| ESRCH | No thread could be found corresponding to that specified by the given thread ID. |
| EDEADLK | A deadlock was detected or the value of thread specifies the calling thread. |
Example:
| pthread_t pthread_self | ( | void | ) |
| int pthread_setspecific | ( | pthread_key_t | key, |
| const void * | value | ||
| ) |
#include <pthread.h>
Associate a thread-specific value with a key obtained via a previous call to pthread_key_create().
| [out] | key | The key associated with the data to set. |
| [in] | value | Pointer to buffer where to store value. |
| 0 | If successful. |
| ENOMEM | Insufficient memory to store threads specific data value. |
| EINVAL | Invalid thread specific data key. |
Example: