61 #ifndef __INCLUDE_PTHREAD_H 62 #define __INCLUDE_PTHREAD_H 68 #include <tinyara/config.h> 69 #include <tinyara/compiler.h> 71 #include <sys/types.h> 80 #include <tinyara/semaphore.h> 88 #ifndef _POSIX_THREADS 89 #define _POSIX_THREADS 92 #ifndef _POSIX_THREAD_ATTR_STACKSIZE 93 #define _POSIX_THREAD_ATTR_STACKSIZE 98 #define PTHREAD_PROCESS_PRIVATE 0 99 #define PTHREAD_PROCESS_SHARED 1 124 #define PTHREAD_MUTEX_NORMAL 0 125 #define PTHREAD_MUTEX_ERRORCHECK 1 126 #define PTHREAD_MUTEX_RECURSIVE 2 127 #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL 131 #define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN 132 #define PTHREAD_STACK_DEFAULT CONFIG_PTHREAD_STACK_DEFAULT 136 #define PTHREAD_INHERIT_SCHED 0 137 #define PTHREAD_EXPLICIT_SCHED 1 141 #define PTHREAD_DEFAULT_PRIORITY 100 145 #define PTHREAD_CANCEL_ENABLE (0) 146 #define PTHREAD_CANCEL_DISABLE (1) 149 #define PTHREAD_CANCEL_DEFERRED (0) 150 #define PTHREAD_CANCEL_ASYNCHRONOUS (1) 154 #define PTHREAD_CANCELED ((FAR void*)ERROR) 158 #define PTHREAD_ONCE_INIT (false) 162 #define PTHREAD_BARRIER_SERIAL_THREAD 0x1000 166 #define PTHREAD_PRIO_NONE SEM_PRIO_NONE 167 #define PTHREAD_PRIO_INHERIT SEM_PRIO_INHERIT 168 #define PTHREAD_PRIO_PROTECT SEM_PRIO_PROTECT 196 #define PTHREAD_MUTEX_STALLED 0 197 #define PTHREAD_MUTEX_ROBUST 1 203 #define _PTHREAD_MFLAGS_ROBUST (1 << 0) 204 #define _PTHREAD_MFLAGS_INCONSISTENT (1 << 1) 205 #define _PTHREAD_MFLAGS_NRECOVERABLE (1 << 2) 222 #define pthread_setname_np(thread, name) \ 223 prctl((int)PR_SET_NAME, (char*)name, (int)thread) 234 #define pthread_getname_np(thread, name) \ 235 prctl((int)PR_GET_NAME, (char*)name, (int)thread) 287 #define PTHREAD_COND_INITIALIZER { {0, 0xffff} } 295 #ifdef CONFIG_PRIORITY_INHERITANCE 298 #ifdef CONFIG_PTHREAD_MUTEX_TYPES 301 #if defined(CONFIG_PTHREAD_MUTEX_BOTH) || defined(CONFIG_PTHREAD_MUTEX_ROBUST) 313 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE 322 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE 325 #ifdef CONFIG_PTHREAD_MUTEX_TYPES 332 #define __PTHREAD_MUTEX_T_DEFINED 1 334 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE 335 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE 336 #define __PTHREAD_MUTEX_DEFAULT_FLAGS 0 338 #define __PTHREAD_MUTEX_DEFAULT_FLAGS _PTHREAD_MFLAGS_ROBUST 342 #if defined(CONFIG_PTHREAD_MUTEX_TYPES) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE) 343 #define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1, \ 344 __PTHREAD_MUTEX_DEFAULT_FLAGS, \ 345 PTHREAD_MUTEX_DEFAULT, 0} 346 #elif defined(CONFIG_PTHREAD_MUTEX_TYPES) 347 #define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1, \ 348 PTHREAD_MUTEX_DEFAULT, 0} 349 #elif !defined(CONFIG_PTHREAD_MUTEX_UNSAFE) 350 #define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1,\ 351 __PTHREAD_MUTEX_DEFAULT_FLAGS} 353 #define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1} 377 #ifdef CONFIG_PTHREAD_CLEANUP 380 typedef CODE void (*pthread_cleanup_t)(FAR
void *arg);
399 #define PTHREAD_RWLOCK_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, \ 400 PTHREAD_COND_INITIALIZER, \ 498 #ifdef CONFIG_PTHREAD_CLEANUP 499 void pthread_cleanup_pop(
int execute);
500 void pthread_cleanup_push(pthread_cleanup_t routine, FAR
void *arg);
537 #define pthread_self() ((pthread_t)getpid()) 548 #define pthread_equal(t1, t2) ((t1) == (t2)) int pthread_cancel(pthread_t thread)
cancel execution of a thread
int pthread_once(FAR pthread_once_t *once_control, CODE void(*init_routine)(void))
dynamic package initialization
Structure of pthread barrier attr configuration.
int pthread_setcancelstate(int state, FAR int *oldstate)
set cancelability state
Structure of pthread rwlock.
int pthread_rwlock_timedrdlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime)
lock a read-write lock for reading
int pthread_kill(pthread_t thread, int sig)
send a signal to a thread
int pthread_attr_destroy(pthread_attr_t *attr)
destroy the thread attributes object
int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
unlock a mutex
int pthread_mutex_trylock(FAR pthread_mutex_t *mutex)
try to lock a mutex
int pthread_attr_setinheritsched(FAR pthread_attr_t *attr, int inheritsched)
set the inheritsched attribute
Structure of pthread condition configuration.
struct pthread_region_s region[2]
Structure of pthread mutex configuration.
int pthread_join(pthread_t thread, FAR pthread_addr_t *value)
wait for thread termination
void pthread_exit(pthread_addr_t value) noreturn_function
thread termination
int pthread_cond_destroy(FAR pthread_cond_t *cond)
destroy condition variables
FAR void * pthread_addr_t
int pthread_rwlock_trywrlock(FAR pthread_rwlock_t *lock)
lock a read-write lock object for reading
int pthread_rwlock_rdlock(pthread_rwlock_t *lock)
lock a read-write lock object for reading
int pthread_attr_getschedparam(FAR const pthread_attr_t *attr, FAR struct sched_param *param)
get the schedparam attribute
int pthread_attr_getstacksize(FAR const pthread_attr_t *attr, long *stackaddr)
get the stacksize attribute
int pthread_mutexattr_getrobust(FAR const pthread_mutexattr_t *attr, FAR int *robust)
get the mutex robust attribute
int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize)
set the stacksize attribute
POSIX-like scheduling parameter structure.
int pthread_mutexattr_getprotocol(FAR const pthread_mutexattr_t *attr, FAR int *protocol)
get the protocol attribute of the mutex attributes object
int pthread_mutexattr_init(FAR pthread_mutexattr_t *attr)
initialize the mutex attributes object
int pthread_mutexattr_setprotocol(FAR pthread_mutexattr_t *attr, int protocol)
set the protocol attribute of the mutex attributes object
int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr, FAR int *inheritsched)
get the inheritsched attribute
int pthread_cond_broadcast(FAR pthread_cond_t *cond)
broadcast a condition
int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
wait on a condition
int pthread_barrier_destroy(FAR pthread_barrier_t *barrier)
destroy a barrier object
int pthread_getschedparam(pthread_t thread, FAR int *policy, FAR struct sched_param *param)
dynamic thread scheduling parameters access
int pthread_mutex_lock(FAR pthread_mutex_t *mutex)
lock a mutex
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
get the mutex type attribute
int pthread_mutexattr_destroy(FAR pthread_mutexattr_t *attr)
destroy the mutex attributes object
int pthread_condattr_destroy(FAR pthread_condattr_t *attr)
destroy the condition variable attributes object
pthread_startroutine_t pthread_func_t
POSIX operating system APIs.
int pthread_rwlock_timedwrlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime)
lock a read-write lock for writing
int pthread_attr_getschedpolicy(FAR const pthread_attr_t *attr, int *policy)
get the schedpolicy attribute
void pthread_yield(void)
yield the processor
int pthread_mutexattr_setpshared(FAR pthread_mutexattr_t *attr, int pshared)
set the process-shared attribute
Structure of pthread attr configuration.
int pthread_barrierattr_destroy(FAR pthread_barrierattr_t *attr)
destroy the barrier attributes object
int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, int policy)
set the schedpolicy attribute
FAR void * pthread_getspecific(pthread_key_t key)
thread-specific data management
int pthread_setcanceltype(int type, FAR int *oldtype)
set cancelability state
int pthread_attr_init(FAR pthread_attr_t *attr)
initialize the thread attributes object
int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared)
get the process-shared attribute of the barrier attributes object
int pthread_cond_signal(FAR pthread_cond_t *cond)
signal a condition
int pthread_rwlock_tryrdlock(FAR pthread_rwlock_t *lock)
lock a read-write lock object for reading
Structure of pthread mutex attr configuration.
int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex, FAR const struct timespec *abstime)
wait on a condition
int pthread_mutexattr_setrobust(FAR pthread_mutexattr_t *attr, int robust)
set the mutex robust attribute
int pthread_condattr_init(FAR pthread_condattr_t *attr)
initialize the condition variable attributes object
int pthread_barrier_init(FAR pthread_barrier_t *barrier, FAR const pthread_barrierattr_t *attr, unsigned int count)
initialize a barrier object
int pthread_setschedprio(pthread_t thread, int prio)
dynamic thread scheduling parameters access
int pthread_setspecific(pthread_key_t key, FAR const void *value)
thread-specific data management
int pthread_cond_init(FAR pthread_cond_t *cond, FAR const pthread_condattr_t *attr)
initialize condition variables
int pthread_key_create(FAR pthread_key_t *key, CODE void(*destructor)(FAR void *))
thread-specific data key creation
int pthread_mutexattr_getpshared(FAR const pthread_mutexattr_t *attr, FAR int *pshared)
get the process-shared attribute
Structure of pthread barrier configuration.
Structure of generic semaphore.
pthread_addr_t(* pthread_startroutine_t)(pthread_addr_t)
FAR struct pthread_mutex_s * flink
int pthread_detach(pthread_t thread)
detach a thread
int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset)
examine and change blocked signals
void pthread_testcancel(void)
set cancelability state
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
set the mutex type attribute
int pthread_attr_setschedparam(FAR pthread_attr_t *attr, FAR const struct sched_param *param)
set the schedparam attribute
int pthread_rwlock_wrlock(FAR pthread_rwlock_t *lock)
lock a read-write lock object for writing
structure represents an elapsed time
int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared)
set the process-shared attribute of the barrier attributes object
int pthread_rwlock_init(FAR pthread_rwlock_t *rw_lock, FAR const pthread_rwlockattr_t *attr)
initialize a read-write lock object
int pthread_setschedparam(pthread_t thread, int policy, FAR const struct sched_param *param)
dynamic thread scheduling parameters access
int pthread_barrierattr_init(FAR pthread_barrierattr_t *attr)
initialize the barrier attributes object
int pthread_rwlock_unlock(FAR pthread_rwlock_t *lock)
unlock a read-write lock object
int pthread_rwlock_destroy(FAR pthread_rwlock_t *rw_lock)
destroy a read-write lock object
int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
destroy a mutex
int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t startroutine, pthread_addr_t arg)
thread creation
Structure of pthread region configuration.
int pthread_barrier_wait(FAR pthread_barrier_t *barrier)
synchronize at a barrier
int pthread_mutex_init(FAR pthread_mutex_t *mutex, FAR const pthread_mutexattr_t *attr)
initialize a mutex