TizenRT Libs&Environment  v2.0 M2
pthread.h File Reference

Pthread APIs. More...

#include <tinyara/config.h>
#include <tinyara/compiler.h>
#include <sys/types.h>
#include <sys/prctl.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <tinyara/semaphore.h>
Include dependency graph for pthread.h:

Go to the source code of this file.

Data Structures

struct  pthread_region_s
 Structure of pthread region configuration. More...
 
struct  pthread_attr_s
 Structure of pthread attr configuration. More...
 
struct  pthread_cond_s
 Structure of pthread condition configuration. More...
 
struct  pthread_mutexattr_s
 Structure of pthread mutex attr configuration. More...
 
struct  pthread_mutex_s
 Structure of pthread mutex configuration. More...
 
struct  pthread_barrierattr_s
 Structure of pthread barrier attr configuration. More...
 
struct  pthread_barrier_s
 Structure of pthread barrier configuration. More...
 
struct  pthread_rwlock_s
 Structure of pthread rwlock. More...
 

Macros

#define _POSIX_THREADS
 
#define _POSIX_THREAD_ATTR_STACKSIZE
 
#define PTHREAD_PROCESS_PRIVATE   0
 
#define PTHREAD_PROCESS_SHARED   1
 
#define PTHREAD_MUTEX_NORMAL   0
 
#define PTHREAD_MUTEX_ERRORCHECK   1
 
#define PTHREAD_MUTEX_RECURSIVE   2
 
#define PTHREAD_MUTEX_DEFAULT   PTHREAD_MUTEX_NORMAL
 
#define PTHREAD_STACK_MIN   CONFIG_PTHREAD_STACK_MIN
 
#define PTHREAD_STACK_DEFAULT   CONFIG_PTHREAD_STACK_DEFAULT
 
#define PTHREAD_INHERIT_SCHED   0
 
#define PTHREAD_EXPLICIT_SCHED   1
 
#define PTHREAD_DEFAULT_PRIORITY   100
 
#define PTHREAD_CANCEL_ENABLE   (0)
 
#define PTHREAD_CANCEL_DISABLE   (1)
 
#define PTHREAD_CANCEL_DEFERRED   (0)
 
#define PTHREAD_CANCEL_ASYNCHRONOUS   (1)
 
#define PTHREAD_CANCELED   ((FAR void*)ERROR)
 
#define PTHREAD_ONCE_INIT   (false)
 
#define PTHREAD_BARRIER_SERIAL_THREAD   0x1000
 
#define PTHREAD_PRIO_NONE   SEM_PRIO_NONE
 
#define PTHREAD_PRIO_INHERIT   SEM_PRIO_INHERIT
 
#define PTHREAD_PRIO_PROTECT   SEM_PRIO_PROTECT
 
#define PTHREAD_MUTEX_STALLED   0
 
#define PTHREAD_MUTEX_ROBUST   1
 
#define _PTHREAD_MFLAGS_ROBUST   (1 << 0) /* Robust (NORMAL) mutex */
 
#define _PTHREAD_MFLAGS_INCONSISTENT   (1 << 1) /* Mutex is in an inconsistent state */
 
#define _PTHREAD_MFLAGS_NRECOVERABLE   (1 << 2) /* Inconsistent mutex has been unlocked */
 
#define PTHREAD_KEYS_MAX   CONFIG_NPTHREAD_KEYS
 
#define PTHREAD_DESTRUCTOR_ITERATIONS   CONFIG_NPTHREAD_DESTRUCTOR_ITERATIONS
 
#define pthread_setname_np(thread, name)   prctl((int)PR_SET_NAME, (char*)name, (int)thread)
 sets the name of pthread More...
 
#define pthread_getname_np(thread, name)   prctl((int)PR_GET_NAME, (char*)name, (int)thread)
 gets the name of pthread More...
 
#define PTHREAD_COND_INITIALIZER   { SEM_INITIALIZER(0) }
 
#define __PTHREAD_MUTEX_T_DEFINED   1
 
#define __PTHREAD_MUTEX_DEFAULT_FLAGS   _PTHREAD_MFLAGS_ROBUST
 
#define PTHREAD_MUTEX_INITIALIZER
 
#define PTHREAD_RWLOCK_INITIALIZER
 
#define pthread_self()   ((pthread_t)getpid())
 get the calling thread ID More...
 
#define pthread_equal(t1, t2)   ((t1) == (t2))
 compare thread IDs More...
 

Typedefs

typedef unsigned int pthread_key_t
 
typedef CODE void(* pthread_destructor_t) (void *arg)
 
typedef FAR void * pthread_addr_t
 
typedef pthread_addr_t(* pthread_startroutine_t) (pthread_addr_t)
 
typedef pthread_startroutine_t pthread_func_t
 
typedef struct pthread_attr_s pthread_attr_t
 
typedef pid_t pthread_t
 
typedef int pthread_condattr_t
 
typedef struct pthread_cond_s pthread_cond_t
 
typedef struct pthread_mutexattr_s pthread_mutexattr_t
 
typedef struct pthread_mutex_s pthread_mutex_t
 
typedef struct pthread_barrierattr_s pthread_barrierattr_t
 
typedef struct pthread_barrier_s pthread_barrier_t
 
typedef bool pthread_once_t
 
typedef struct pthread_rwlock_s pthread_rwlock_t
 
typedef int pthread_rwlockattr_t
 

Functions

int pthread_create (FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t startroutine, pthread_addr_t arg)
 thread creation More...
 
int pthread_detach (pthread_t thread)
 detach a thread More...
 
void pthread_exit (pthread_addr_t value) noreturn_function
 thread termination More...
 
int pthread_cancel (pthread_t thread)
 cancel execution of a thread More...
 
int pthread_setcancelstate (int state, FAR int *oldstate)
 set cancelability state More...
 
int pthread_setcanceltype (int type, FAR int *oldtype)
 set cancelability state More...
 
void pthread_testcancel (void)
 set cancelability state More...
 
int pthread_join (pthread_t thread, FAR pthread_addr_t *value)
 wait for thread termination More...
 
int pthread_tryjoin_np (pthread_t thread, FAR pthread_addr_t *pexit_value)
 performs a nonblocking join with the thread thread, returning the exit status of the thread in *pexit_value More...
 
void pthread_yield (void)
 yield the processor More...
 
int pthread_getschedparam (pthread_t thread, FAR int *policy, FAR struct sched_param *param)
 dynamic thread scheduling parameters access More...
 
int pthread_setschedparam (pthread_t thread, int policy, FAR const struct sched_param *param)
 dynamic thread scheduling parameters access More...
 
int pthread_setschedprio (pthread_t thread, int prio)
 dynamic thread scheduling parameters access More...
 
int pthread_key_create (FAR pthread_key_t *key, CODE void(*destructor)(FAR void *))
 thread-specific data key creation More...
 
int pthread_setspecific (pthread_key_t key, FAR const void *value)
 thread-specific data management More...
 
void * pthread_getspecific (pthread_key_t key)
 thread-specific data management More...
 
int pthread_key_delete (pthread_key_t key)
 thread-specific data key deletion More...
 
int pthread_mutex_init (FAR pthread_mutex_t *mutex, FAR const pthread_mutexattr_t *attr)
 initialize a mutex More...
 
int pthread_mutex_destroy (FAR pthread_mutex_t *mutex)
 destroy a mutex More...
 
int pthread_mutex_lock (FAR pthread_mutex_t *mutex)
 lock a mutex More...
 
int pthread_mutex_trylock (FAR pthread_mutex_t *mutex)
 try to lock a mutex More...
 
int pthread_mutex_unlock (FAR pthread_mutex_t *mutex)
 unlock a mutex More...
 
int pthread_cond_init (FAR pthread_cond_t *cond, FAR const pthread_condattr_t *attr)
 initialize condition variables More...
 
int pthread_cond_destroy (FAR pthread_cond_t *cond)
 destroy condition variables More...
 
int pthread_cond_broadcast (FAR pthread_cond_t *cond)
 broadcast a condition More...
 
int pthread_cond_signal (FAR pthread_cond_t *cond)
 signal a condition More...
 
int pthread_cond_wait (FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
 wait on a condition More...
 
int pthread_cond_timedwait (FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex, FAR const struct timespec *abstime)
 wait on a condition More...
 
int pthread_barrier_destroy (FAR pthread_barrier_t *barrier)
 destroy a barrier object More...
 
int pthread_barrier_init (FAR pthread_barrier_t *barrier, FAR const pthread_barrierattr_t *attr, unsigned int count)
 initialize a barrier object More...
 
int pthread_barrier_wait (FAR pthread_barrier_t *barrier)
 synchronize at a barrier More...
 
int pthread_once (FAR pthread_once_t *once_control, CODE void(*init_routine)(void))
 dynamic package initialization More...
 
int pthread_kill (pthread_t thread, int sig)
 send a signal to a thread More...
 
int pthread_sigmask (int how, FAR const sigset_t *set, FAR sigset_t *oset)
 examine and change blocked signals More...
 
int pthread_attr_init (FAR pthread_attr_t *attr)
 initialize the thread attributes object More...
 
int pthread_attr_destroy (pthread_attr_t *attr)
 destroy the thread attributes object More...
 
int pthread_attr_setschedpolicy (FAR pthread_attr_t *attr, int policy)
 set the schedpolicy attribute More...
 
int pthread_attr_getschedpolicy (FAR const pthread_attr_t *attr, int *policy)
 get the schedpolicy attribute More...
 
int pthread_attr_setschedparam (FAR pthread_attr_t *attr, FAR const struct sched_param *param)
 set the schedparam attribute More...
 
int pthread_attr_getschedparam (FAR const pthread_attr_t *attr, FAR struct sched_param *param)
 get the schedparam attribute More...
 
int pthread_attr_setinheritsched (FAR pthread_attr_t *attr, int inheritsched)
 set the inheritsched attribute More...
 
int pthread_attr_getinheritsched (FAR const pthread_attr_t *attr, FAR int *inheritsched)
 get the inheritsched attribute More...
 
int pthread_attr_setstacksize (FAR pthread_attr_t *attr, long stacksize)
 set the stacksize attribute More...
 
int pthread_attr_getstacksize (FAR const pthread_attr_t *attr, long *stackaddr)
 get the stacksize attribute More...
 
int pthread_mutexattr_init (FAR pthread_mutexattr_t *attr)
 initialize the mutex attributes object More...
 
int pthread_mutexattr_destroy (FAR pthread_mutexattr_t *attr)
 destroy the mutex attributes object More...
 
int pthread_mutexattr_getpshared (FAR const pthread_mutexattr_t *attr, FAR int *pshared)
 get the process-shared attribute More...
 
int pthread_mutexattr_setpshared (FAR pthread_mutexattr_t *attr, int pshared)
 set the process-shared attribute More...
 
int pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type)
 get the mutex type attribute More...
 
int pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type)
 set the mutex type attribute More...
 
int pthread_mutexattr_getprotocol (FAR const pthread_mutexattr_t *attr, FAR int *protocol)
 get the protocol attribute of the mutex attributes object More...
 
int pthread_mutexattr_setprotocol (FAR pthread_mutexattr_t *attr, int protocol)
 set the protocol attribute of the mutex attributes object More...
 
int pthread_mutexattr_getrobust (FAR const pthread_mutexattr_t *attr, FAR int *robust)
 get the mutex robust attribute More...
 
int pthread_mutexattr_setrobust (FAR pthread_mutexattr_t *attr, int robust)
 set the mutex robust attribute More...
 
int pthread_condattr_init (FAR pthread_condattr_t *attr)
 initialize the condition variable attributes object More...
 
int pthread_condattr_destroy (FAR pthread_condattr_t *attr)
 destroy the condition variable attributes object More...
 
int pthread_barrierattr_destroy (FAR pthread_barrierattr_t *attr)
 destroy the barrier attributes object More...
 
int pthread_barrierattr_init (FAR pthread_barrierattr_t *attr)
 initialize the barrier attributes object More...
 
int pthread_barrierattr_getpshared (FAR const pthread_barrierattr_t *attr, FAR int *pshared)
 get the process-shared attribute of the barrier attributes object More...
 
int pthread_barrierattr_setpshared (FAR pthread_barrierattr_t *attr, int pshared)
 set the process-shared attribute of the barrier attributes object More...
 
int pthread_rwlock_destroy (FAR pthread_rwlock_t *rw_lock)
 destroy a read-write lock object More...
 
int pthread_rwlock_init (FAR pthread_rwlock_t *rw_lock, FAR const pthread_rwlockattr_t *attr)
 initialize a read-write lock object More...
 
int pthread_rwlock_rdlock (pthread_rwlock_t *lock)
 lock a read-write lock object for reading More...
 
int pthread_rwlock_timedrdlock (FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime)
 lock a read-write lock for reading More...
 
int pthread_rwlock_timedwrlock (FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime)
 lock a read-write lock for writing More...
 
int pthread_rwlock_tryrdlock (FAR pthread_rwlock_t *lock)
 lock a read-write lock object for reading More...
 
int pthread_rwlock_trywrlock (FAR pthread_rwlock_t *lock)
 lock a read-write lock object for reading More...
 
int pthread_rwlock_unlock (FAR pthread_rwlock_t *lock)
 unlock a read-write lock object More...
 
int pthread_rwlock_wrlock (FAR pthread_rwlock_t *lock)
 lock a read-write lock object for writing More...
 

Detailed Description

Pthread APIs.

Definition in file pthread.h.

Macro Definition Documentation

#define __PTHREAD_MUTEX_DEFAULT_FLAGS   _PTHREAD_MFLAGS_ROBUST

Definition at line 345 of file pthread.h.

#define __PTHREAD_MUTEX_T_DEFINED   1

Definition at line 339 of file pthread.h.

#define _POSIX_THREAD_ATTR_STACKSIZE

Definition at line 93 of file pthread.h.

#define _POSIX_THREADS

Definition at line 89 of file pthread.h.

#define _PTHREAD_MFLAGS_INCONSISTENT   (1 << 1) /* Mutex is in an inconsistent state */

Definition at line 204 of file pthread.h.

#define _PTHREAD_MFLAGS_NRECOVERABLE   (1 << 2) /* Inconsistent mutex has been unlocked */

Definition at line 205 of file pthread.h.

#define _PTHREAD_MFLAGS_ROBUST   (1 << 0) /* Robust (NORMAL) mutex */

Definition at line 203 of file pthread.h.

#define PTHREAD_BARRIER_SERIAL_THREAD   0x1000

Definition at line 162 of file pthread.h.

#define PTHREAD_CANCEL_ASYNCHRONOUS   (1)

Definition at line 150 of file pthread.h.

#define PTHREAD_CANCEL_DEFERRED   (0)

Definition at line 149 of file pthread.h.

#define PTHREAD_CANCEL_DISABLE   (1)

Definition at line 146 of file pthread.h.

#define PTHREAD_CANCEL_ENABLE   (0)

Definition at line 145 of file pthread.h.

#define PTHREAD_CANCELED   ((FAR void*)ERROR)

Definition at line 154 of file pthread.h.

#define PTHREAD_COND_INITIALIZER   { SEM_INITIALIZER(0) }

Definition at line 294 of file pthread.h.

#define PTHREAD_DEFAULT_PRIORITY   100

Definition at line 141 of file pthread.h.

#define PTHREAD_DESTRUCTOR_ITERATIONS   CONFIG_NPTHREAD_DESTRUCTOR_ITERATIONS

Definition at line 211 of file pthread.h.

#define PTHREAD_EXPLICIT_SCHED   1

Definition at line 137 of file pthread.h.

#define PTHREAD_INHERIT_SCHED   0

Definition at line 136 of file pthread.h.

#define PTHREAD_KEYS_MAX   CONFIG_NPTHREAD_KEYS

Definition at line 210 of file pthread.h.

#define PTHREAD_MUTEX_DEFAULT   PTHREAD_MUTEX_NORMAL

Definition at line 127 of file pthread.h.

#define PTHREAD_MUTEX_ERRORCHECK   1

Definition at line 125 of file pthread.h.

#define PTHREAD_MUTEX_INITIALIZER
Value:
{NULL, SEM_INITIALIZER(1), -1,\
#define SEM_INITIALIZER(c)
Sem initializer.
Definition: semaphore.h:139
#define __PTHREAD_MUTEX_DEFAULT_FLAGS
Definition: pthread.h:345

Definition at line 357 of file pthread.h.

#define PTHREAD_MUTEX_NORMAL   0

Definition at line 124 of file pthread.h.

#define PTHREAD_MUTEX_RECURSIVE   2

Definition at line 126 of file pthread.h.

#define PTHREAD_MUTEX_ROBUST   1

Definition at line 197 of file pthread.h.

#define PTHREAD_MUTEX_STALLED   0

Definition at line 196 of file pthread.h.

#define PTHREAD_ONCE_INIT   (false)

Definition at line 158 of file pthread.h.

#define PTHREAD_PRIO_INHERIT   SEM_PRIO_INHERIT

Definition at line 167 of file pthread.h.

#define PTHREAD_PRIO_NONE   SEM_PRIO_NONE

Definition at line 166 of file pthread.h.

#define PTHREAD_PRIO_PROTECT   SEM_PRIO_PROTECT

Definition at line 168 of file pthread.h.

#define PTHREAD_PROCESS_PRIVATE   0

Definition at line 98 of file pthread.h.

#define PTHREAD_PROCESS_SHARED   1

Definition at line 99 of file pthread.h.

#define PTHREAD_RWLOCK_INITIALIZER
Value:
0, 0, false}
#define PTHREAD_COND_INITIALIZER
Definition: pthread.h:294
#define PTHREAD_MUTEX_INITIALIZER
Definition: pthread.h:357

Definition at line 406 of file pthread.h.

#define PTHREAD_STACK_DEFAULT   CONFIG_PTHREAD_STACK_DEFAULT

Definition at line 132 of file pthread.h.

#define PTHREAD_STACK_MIN   CONFIG_PTHREAD_STACK_MIN

Definition at line 131 of file pthread.h.

Typedef Documentation

typedef FAR void* pthread_addr_t

Definition at line 255 of file pthread.h.

Definition at line 280 of file pthread.h.

Definition at line 380 of file pthread.h.

Definition at line 370 of file pthread.h.

Definition at line 293 of file pthread.h.

typedef int pthread_condattr_t

Definition at line 284 of file pthread.h.

typedef CODE void(* pthread_destructor_t) (void *arg)

Definition at line 254 of file pthread.h.

Definition at line 258 of file pthread.h.

typedef unsigned int pthread_key_t

Definition at line 253 of file pthread.h.

Definition at line 337 of file pthread.h.

Definition at line 312 of file pthread.h.

typedef bool pthread_once_t

Definition at line 382 of file pthread.h.

Definition at line 402 of file pthread.h.

typedef int pthread_rwlockattr_t

Definition at line 404 of file pthread.h.

typedef pthread_addr_t(* pthread_startroutine_t) (pthread_addr_t)

Definition at line 257 of file pthread.h.

typedef pid_t pthread_t

Definition at line 282 of file pthread.h.