Tizen RT Libs&Environment  v1.1 D4
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_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   { {0, 0xffff} }
 
#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 int pthread_key_t
 
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...
 
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...
 
FAR void * pthread_getspecific (pthread_key_t key)
 thread-specific data management 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

◆ __PTHREAD_MUTEX_DEFAULT_FLAGS

#define __PTHREAD_MUTEX_DEFAULT_FLAGS   _PTHREAD_MFLAGS_ROBUST

Definition at line 338 of file pthread.h.

◆ __PTHREAD_MUTEX_T_DEFINED

#define __PTHREAD_MUTEX_T_DEFINED   1

Definition at line 332 of file pthread.h.

◆ _POSIX_THREAD_ATTR_STACKSIZE

#define _POSIX_THREAD_ATTR_STACKSIZE

Definition at line 93 of file pthread.h.

◆ _POSIX_THREADS

#define _POSIX_THREADS

Definition at line 89 of file pthread.h.

◆ _PTHREAD_MFLAGS_INCONSISTENT

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

Definition at line 204 of file pthread.h.

◆ _PTHREAD_MFLAGS_NRECOVERABLE

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

Definition at line 205 of file pthread.h.

◆ _PTHREAD_MFLAGS_ROBUST

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

Definition at line 203 of file pthread.h.

◆ PTHREAD_BARRIER_SERIAL_THREAD

#define PTHREAD_BARRIER_SERIAL_THREAD   0x1000

Definition at line 162 of file pthread.h.

◆ PTHREAD_CANCEL_ASYNCHRONOUS

#define PTHREAD_CANCEL_ASYNCHRONOUS   (1)

Definition at line 150 of file pthread.h.

◆ PTHREAD_CANCEL_DEFERRED

#define PTHREAD_CANCEL_DEFERRED   (0)

Definition at line 149 of file pthread.h.

◆ PTHREAD_CANCEL_DISABLE

#define PTHREAD_CANCEL_DISABLE   (1)

Definition at line 146 of file pthread.h.

◆ PTHREAD_CANCEL_ENABLE

#define PTHREAD_CANCEL_ENABLE   (0)

Definition at line 145 of file pthread.h.

◆ PTHREAD_CANCELED

#define PTHREAD_CANCELED   ((FAR void*)ERROR)

Definition at line 154 of file pthread.h.

◆ PTHREAD_COND_INITIALIZER

#define PTHREAD_COND_INITIALIZER   { {0, 0xffff} }

Definition at line 287 of file pthread.h.

◆ PTHREAD_DEFAULT_PRIORITY

#define PTHREAD_DEFAULT_PRIORITY   100

Definition at line 141 of file pthread.h.

◆ PTHREAD_EXPLICIT_SCHED

#define PTHREAD_EXPLICIT_SCHED   1

Definition at line 137 of file pthread.h.

◆ PTHREAD_INHERIT_SCHED

#define PTHREAD_INHERIT_SCHED   0

Definition at line 136 of file pthread.h.

◆ PTHREAD_MUTEX_DEFAULT

#define PTHREAD_MUTEX_DEFAULT   PTHREAD_MUTEX_NORMAL

Definition at line 127 of file pthread.h.

◆ PTHREAD_MUTEX_ERRORCHECK

#define PTHREAD_MUTEX_ERRORCHECK   1

Definition at line 125 of file pthread.h.

◆ PTHREAD_MUTEX_INITIALIZER

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

Definition at line 350 of file pthread.h.

◆ PTHREAD_MUTEX_NORMAL

#define PTHREAD_MUTEX_NORMAL   0

Definition at line 124 of file pthread.h.

◆ PTHREAD_MUTEX_RECURSIVE

#define PTHREAD_MUTEX_RECURSIVE   2

Definition at line 126 of file pthread.h.

◆ PTHREAD_MUTEX_ROBUST

#define PTHREAD_MUTEX_ROBUST   1

Definition at line 197 of file pthread.h.

◆ PTHREAD_MUTEX_STALLED

#define PTHREAD_MUTEX_STALLED   0

Definition at line 196 of file pthread.h.

◆ PTHREAD_ONCE_INIT

#define PTHREAD_ONCE_INIT   (false)

Definition at line 158 of file pthread.h.

◆ PTHREAD_PRIO_INHERIT

#define PTHREAD_PRIO_INHERIT   SEM_PRIO_INHERIT

Definition at line 167 of file pthread.h.

◆ PTHREAD_PRIO_NONE

#define PTHREAD_PRIO_NONE   SEM_PRIO_NONE

Definition at line 166 of file pthread.h.

◆ PTHREAD_PRIO_PROTECT

#define PTHREAD_PRIO_PROTECT   SEM_PRIO_PROTECT

Definition at line 168 of file pthread.h.

◆ PTHREAD_PROCESS_PRIVATE

#define PTHREAD_PROCESS_PRIVATE   0

Definition at line 98 of file pthread.h.

◆ PTHREAD_PROCESS_SHARED

#define PTHREAD_PROCESS_SHARED   1

Definition at line 99 of file pthread.h.

◆ PTHREAD_RWLOCK_INITIALIZER

#define PTHREAD_RWLOCK_INITIALIZER
Value:
PTHREAD_COND_INITIALIZER, \
0, 0, false}
#define PTHREAD_MUTEX_INITIALIZER
Definition: pthread.h:350

Definition at line 399 of file pthread.h.

◆ PTHREAD_STACK_DEFAULT

#define PTHREAD_STACK_DEFAULT   CONFIG_PTHREAD_STACK_DEFAULT

Definition at line 132 of file pthread.h.

◆ PTHREAD_STACK_MIN

#define PTHREAD_STACK_MIN   CONFIG_PTHREAD_STACK_MIN

Definition at line 131 of file pthread.h.

Typedef Documentation

◆ pthread_addr_t

typedef FAR void* pthread_addr_t

Definition at line 248 of file pthread.h.

◆ pthread_attr_t

Definition at line 273 of file pthread.h.

◆ pthread_barrier_t

Definition at line 373 of file pthread.h.

◆ pthread_barrierattr_t

Definition at line 363 of file pthread.h.

◆ pthread_cond_t

Definition at line 286 of file pthread.h.

◆ pthread_condattr_t

typedef int pthread_condattr_t

Definition at line 277 of file pthread.h.

◆ pthread_func_t

Definition at line 251 of file pthread.h.

◆ pthread_key_t

typedef int pthread_key_t

Definition at line 247 of file pthread.h.

◆ pthread_mutex_t

Definition at line 330 of file pthread.h.

◆ pthread_mutexattr_t

Definition at line 305 of file pthread.h.

◆ pthread_once_t

typedef bool pthread_once_t

Definition at line 375 of file pthread.h.

◆ pthread_rwlock_t

Definition at line 395 of file pthread.h.

◆ pthread_rwlockattr_t

typedef int pthread_rwlockattr_t

Definition at line 397 of file pthread.h.

◆ pthread_startroutine_t

typedef pthread_addr_t(* pthread_startroutine_t) (pthread_addr_t)

Definition at line 250 of file pthread.h.

◆ pthread_t

typedef pid_t pthread_t

Definition at line 275 of file pthread.h.