Tizen RT Libs&Environment  v1.1 D4
pthread.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /********************************************************************************
19  * include/pthread.h
20  *
21  * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ********************************************************************************/
58 
61 #ifndef __INCLUDE_PTHREAD_H
62 #define __INCLUDE_PTHREAD_H
63 
64 /********************************************************************************
65  * Included Files
66  ********************************************************************************/
67 
68 #include <tinyara/config.h> /* Default settings */
69 #include <tinyara/compiler.h> /* Compiler settings, noreturn_function */
70 
71 #include <sys/types.h> /* Needed for general types */
72 #include <sys/prctl.h> /* Needed by pthread_[set|get]name_np */
73 
74 #include <stdint.h> /* C99 fixed width integer types */
75 #include <stdbool.h> /* C99 boolean types */
76 #include <unistd.h> /* For getpid */
77 #include <signal.h> /* Needed for sigset_t */
78 #include <time.h> /* Needed for struct timespec */
79 
80 #include <tinyara/semaphore.h> /* For sem_t and SEM_PRIO_* defines */
81 
82 /********************************************************************************
83  * Pre-processor Definitions
84  ********************************************************************************/
85 
86 /* Standard POSIX switches */
87 
88 #ifndef _POSIX_THREADS
89 #define _POSIX_THREADS
90 #endif
91 
92 #ifndef _POSIX_THREAD_ATTR_STACKSIZE
93 #define _POSIX_THREAD_ATTR_STACKSIZE
94 #endif
95 
96 /* Values for the process shared (pshared) attribute */
97 
98 #define PTHREAD_PROCESS_PRIVATE 0
99 #define PTHREAD_PROCESS_SHARED 1
100 
101 /* Values for the mutext type attribute:
102  *
103  * PTHREAD_MUTEX_NORMAL: This type of mutex does not detect deadlock. A thread
104  * attempting to relock this mutex without first unlocking it will deadlock.
105  * Attempting to unlock a mutex locked by a different thread results in undefined
106  * behavior. Attempting to unlock an unlocked mutex results in undefined behavior.
107  * PTHREAD_MUTEX_ERRORCHECK
108  * This type of mutex provides error checking. A thread attempting to relock this
109  * mutex without first unlocking it will return with an error. A thread attempting
110  * to unlock a mutex which another thread has locked will return with an error. A
111  * thread attempting to unlock an unlocked mutex will return with an error.
112  * PTHREAD_MUTEX_RECURSIVE
113  * A thread attempting to relock this mutex without first unlocking it will succeed
114  * in locking the mutex. The relocking deadlock which can occur with mutexes of type
115  * PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex. Multiple locks of this
116  * mutex require the same number of unlocks to release the mutex before another thread
117  * can acquire the mutex. A thread attempting to unlock a mutex which another thread
118  * has locked will return with an error. A thread attempting to unlock an unlocked
119  * mutex will return with an error.
120  * PTHREAD_MUTEX_DEFAULT
121  * An implementation is allowed to map this mutex to one of the other mutex types.
122  */
123 
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
128 
129 /* Valid ranges for the pthread stacksize attribute */
130 
131 #define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
132 #define PTHREAD_STACK_DEFAULT CONFIG_PTHREAD_STACK_DEFAULT
133 
134 /* Values for the pthread inheritsched attribute */
135 
136 #define PTHREAD_INHERIT_SCHED 0
137 #define PTHREAD_EXPLICIT_SCHED 1
138 
139 /* Default priority */
140 
141 #define PTHREAD_DEFAULT_PRIORITY 100
142 
143 /* Cancellation states used by pthread_setcancelstate() */
144 
145 #define PTHREAD_CANCEL_ENABLE (0)
146 #define PTHREAD_CANCEL_DISABLE (1)
147 
148 /* Cancellation types used by pthread_setcanceltype() */
149 #define PTHREAD_CANCEL_DEFERRED (0)
150 #define PTHREAD_CANCEL_ASYNCHRONOUS (1)
151 
152 /* Thread return value when a pthread is canceled */
153 
154 #define PTHREAD_CANCELED ((FAR void*)ERROR)
155 
156 /* Used to initialize a pthread_once_t */
157 
158 #define PTHREAD_ONCE_INIT (false)
159 
160 /* This is returned by pthread_wait. It must not match any errno in errno.h */
161 
162 #define PTHREAD_BARRIER_SERIAL_THREAD 0x1000
163 
164 /* Values for protocol mutex attribute */
165 
166 #define PTHREAD_PRIO_NONE SEM_PRIO_NONE
167 #define PTHREAD_PRIO_INHERIT SEM_PRIO_INHERIT
168 #define PTHREAD_PRIO_PROTECT SEM_PRIO_PROTECT
169 
170 /*
171  * Values for robust argument of pthread_mutexattr_get/setrobust
172  *
173  * PTHREAD_MUTEX_STALLED - No special actions are taken if the owner of the
174  * mutex is terminated while holding the mutex lock. This can lead to
175  * deadlocks if no other thread can unlock the mutex. This is the standard
176  * default value (NuttX permits you to override that default behavior
177  * with a configuration option).
178  *
179  * PTHREAD_MUTEX_ROBUST - If the process containing the owning thread of a
180  * robust mutex terminates while holding the mutex lock, the next thread
181  * that acquires the mutex will be notified about the termination by the
182  * return value EOWNERDEAD from the locking function. If the owning thread
183  * of a robust mutex terminates while holding the mutex lock, the next
184  * thread that attempts to acquire the mutex may be notified about the
185  * termination by the return value EOWNERDEAD. The notified thread can
186  * then attempt to make the state protected by the mutex consistent again,
187  * and if successful can mark the mutex state as consistent by calling
188  * pthread_mutex_consistent(). After a subsequent successful call to
189  * pthread_mutex_unlock(), the mutex lock will be released and can be used
190  * normally by other threads. If the mutex is unlocked without a call to
191  * pthread_mutex_consistent(), it will be in a permanently unusable state
192  * and all attempts to lock the mutex will fail with the error
193  * ENOTRECOVERABLE. The only permissible operation on such a mutex is
194  * pthread_mutex_destroy().
195  */
196 #define PTHREAD_MUTEX_STALLED 0
197 #define PTHREAD_MUTEX_ROBUST 1
198 
199 /*
200  * Values for struct pthread_mutex_s flags. These are non-standard and
201  * intended only for internal use within the OS.
202  */
203 #define _PTHREAD_MFLAGS_ROBUST (1 << 0) /* Robust (NORMAL) mutex */
204 #define _PTHREAD_MFLAGS_INCONSISTENT (1 << 1) /* Mutex is in an inconsistent state */
205 #define _PTHREAD_MFLAGS_NRECOVERABLE (1 << 2) /* Inconsistent mutex has been unlocked */
206 
207 /* Definitions to map some non-standard, BSD thread management interfaces to
208  * the non-standard Linux-like prctl() interface. Since these are simple
209  * mappings to prctl, they will return 0 on success and -1 on failure with the
210  * err number in errno. This is an inconsistency with the pthread interfaces.
211  */
212 
222 #define pthread_setname_np(thread, name) \
223  prctl((int)PR_SET_NAME, (char*)name, (int)thread)
224 
234 #define pthread_getname_np(thread, name) \
235  prctl((int)PR_GET_NAME, (char*)name, (int)thread)
236 
237 /********************************************************************************
238  * Global Type Declarations
239  ********************************************************************************/
240 
241 #ifdef __cplusplus
242 extern "C" {
243 #endif
244 
245 /* pthread-specific types */
246 
247 typedef int pthread_key_t;
248 typedef FAR void *pthread_addr_t;
249 
252 
258  void *address; /* start address of the region */
259  uint32_t size; /* size of the region in bytes */
260  uint32_t attributes; /* attributes of the region */
261 };
267  size_t stacksize; /* Size of the stack allocated for the pthread */
268  int16_t priority; /* Priority of the pthread */
269  uint8_t policy; /* Pthread scheduler policy */
270  uint8_t inheritsched; /* Inherit parent prio/policy? */
271  struct pthread_region_s region[2]; /* space for user-space region if MPU supported */
272 };
274 
275 typedef pid_t pthread_t;
276 
277 typedef int pthread_condattr_t;
278 
285 };
287 #define PTHREAD_COND_INITIALIZER { {0, 0xffff} }
288 
294  uint8_t pshared:1; /* PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED */
295 #ifdef CONFIG_PRIORITY_INHERITANCE
296  uint8_t proto:2; /* See PTHREAD_PRIO_* definitions */
297 #endif
298 #ifdef CONFIG_PTHREAD_MUTEX_TYPES
299  uint8_t type:2; /* Type of the mutex. See PTHREAD_MUTEX_* definitions */
300 #endif
301 #if defined(CONFIG_PTHREAD_MUTEX_BOTH) || defined(CONFIG_PTHREAD_MUTEX_ROBUST)
302  uint8_t robust:1; /* PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST */
303 #endif
304 };
306 
312 
313 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
314  /* Supports a singly linked list */
315 
316  FAR struct pthread_mutex_s *flink;
317 #endif
318  /* Payload */
319 
320  sem_t sem; /* Semaphore underlying the implementation of the mutex */
321  int pid; /* ID of the holder of the mutex */
322 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
323  uint8_t flags; /* See _PTHREAD_MFLAGS_* */
324 #endif
325 #ifdef CONFIG_PTHREAD_MUTEX_TYPES
326  uint8_t type; /* Type of the mutex. See PTHREAD_MUTEX_* definitions */
327  int nlocks; /* The number of recursive locks held */
328 #endif
329 };
331 
332 #define __PTHREAD_MUTEX_T_DEFINED 1
333 
334 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
335 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
336 #define __PTHREAD_MUTEX_DEFAULT_FLAGS 0
337 #else
338 #define __PTHREAD_MUTEX_DEFAULT_FLAGS _PTHREAD_MFLAGS_ROBUST
339 #endif
340 #endif
341 
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}
352 #else
353 #define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1}
354 #endif
355 
361  int pshared;
362 };
364 
371  unsigned int count;
372 };
374 
375 typedef bool pthread_once_t;
376 
377 #ifdef CONFIG_PTHREAD_CLEANUP
378 /* This type describes the pthread cleanup callback (non-standard) */
379 
380 typedef CODE void (*pthread_cleanup_t)(FAR void *arg);
381 #endif
382 
390  unsigned int num_readers;
391  unsigned int num_writers;
393 };
394 
396 
398 
399 #define PTHREAD_RWLOCK_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, \
400  PTHREAD_COND_INITIALIZER, \
401  0, 0, false}
402 
403 /* Forware references */
404 
405 struct sched_param; /* Defined in sched.h */
406 
407 /********************************************************************************
408  * Global Variables
409  ********************************************************************************/
410 
411 /********************************************************************************
412  * Global Function Prototypes
413  ********************************************************************************/
414 
415 /* Initializes a thread attributes object (attr) with default values for all of
416  * the individual attributes used by a given implementation.
417  */
418 
419 /* To create a thread object and runnable thread, a routine must be specified
420  * as the new thread's start routine. An argument may be passed to this
421  * routine, as an untyped address; an untyped address may also be returned as
422  * the routine's value. An attributes object may be used to specify details
423  * about the kind of thread being created.
424  */
425 
434 int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t startroutine, pthread_addr_t arg);
435 
436 /* A thread object may be "detached" to specify that the return value and
437  * completion status will not be requested.
438  */
447 int pthread_detach(pthread_t thread);
448 
449 /* A thread may terminate it's own execution or the execution of another
450  * thread.
451  */
460 void pthread_exit(pthread_addr_t value) noreturn_function;
469 int pthread_cancel(pthread_t thread);
478 int pthread_setcancelstate(int state, FAR int *oldstate);
486 int pthread_setcanceltype(int type, FAR int *oldtype);
487 
495 void pthread_testcancel(void);
496 
497 /* A thread may set up cleanup functions to execut when the thread exits or is canceled. */
498 #ifdef CONFIG_PTHREAD_CLEANUP
499 void pthread_cleanup_pop(int execute);
500 void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg);
501 #endif
502 
503 /* A thread can await termination of another thread and retrieve the return
504  * value of the thread.
505  */
506 
515 int pthread_join(pthread_t thread, FAR pthread_addr_t *value);
516 
517 /* A thread may tell the scheduler that its processor can be made available. */
526 void pthread_yield(void);
527 
528 /* A thread may obtain a copy of its own thread handle. */
537 #define pthread_self() ((pthread_t)getpid())
538 
539 /* Compare two thread IDs. */
548 #define pthread_equal(t1, t2) ((t1) == (t2))
549 
550 /* Thread scheduling parameters */
559 int pthread_getschedparam(pthread_t thread, FAR int *policy, FAR struct sched_param *param);
568 int pthread_setschedparam(pthread_t thread, int policy, FAR const struct sched_param *param);
576 int pthread_setschedprio(pthread_t thread, int prio);
577 
578 /* Thread-specific Data Interfaces */
587 int pthread_key_create(FAR pthread_key_t *key, CODE void (*destructor)(FAR void *));
596 int pthread_setspecific(pthread_key_t key, FAR const void *value);
605 FAR void *pthread_getspecific(pthread_key_t key);
610 int pthread_key_delete(pthread_key_t key);
615 /* The following routines create, delete, lock and unlock mutexes. */
616 
625 int pthread_mutex_init(FAR pthread_mutex_t *mutex, FAR const pthread_mutexattr_t *attr);
634 int pthread_mutex_destroy(FAR pthread_mutex_t *mutex);
643 int pthread_mutex_lock(FAR pthread_mutex_t *mutex);
652 int pthread_mutex_trylock(FAR pthread_mutex_t *mutex);
661 int pthread_mutex_unlock(FAR pthread_mutex_t *mutex);
662 
663 /* A thread can create and delete condition variables. */
672 int pthread_cond_init(FAR pthread_cond_t *cond, FAR const pthread_condattr_t *attr);
681 int pthread_cond_destroy(FAR pthread_cond_t *cond);
682 
683 /* A thread can signal to and broadcast on a condition variable. */
701 int pthread_cond_signal(FAR pthread_cond_t *cond);
702 
703 /* A thread can wait for a condition variable to be signalled or broadcast. */
712 int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex);
713 
714 /* A thread can perform a timed wait on a condition variable. */
723 int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex, FAR const struct timespec *abstime);
724 
725 /* Barriers */
743 int pthread_barrier_init(FAR pthread_barrier_t *barrier, FAR const pthread_barrierattr_t *attr, unsigned int count);
752 int pthread_barrier_wait(FAR pthread_barrier_t *barrier);
753 
754 /* Pthread initialization */
763 int pthread_once(FAR pthread_once_t *once_control, CODE void (*init_routine)(void));
764 
765 /* Pthread signal management APIs */
774 int pthread_kill(pthread_t thread, int sig);
783 int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset);
784 
795 int pthread_attr_init(FAR pthread_attr_t *attr);
796 
797 /* An attributes object can be deleted when it is no longer needed. */
798 
806 
807 /* Set or obtain the default scheduling algorithm */
808 
815 int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, int policy);
822 int pthread_attr_getschedpolicy(FAR const pthread_attr_t *attr, int *policy);
829 int pthread_attr_setschedparam(FAR pthread_attr_t *attr, FAR const struct sched_param *param);
836 int pthread_attr_getschedparam(FAR const pthread_attr_t *attr, FAR struct sched_param *param);
843 int pthread_attr_setinheritsched(FAR pthread_attr_t *attr, int inheritsched);
850 int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr, FAR int *inheritsched);
851 
852 /* Set or obtain the default stack size */
859 int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize);
860 
867 int pthread_attr_getstacksize(FAR const pthread_attr_t *attr, long *stackaddr);
868 
869 /* Create, operate on, and destroy mutex attributes. */
890 int pthread_mutexattr_getpshared(FAR const pthread_mutexattr_t *attr, FAR int *pshared);
897 int pthread_mutexattr_setpshared(FAR pthread_mutexattr_t *attr, int pshared);
904 int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
919  FAR int *protocol);
927  int protocol);
935  FAR int *robust);
943  int robust);
944 
945 /* Operations on condition variables */
960 
961 /* Barrier attributes */
982 int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared);
989 int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared);
990 
991 /* Pthread rwlock */
992 
999 int pthread_rwlock_destroy(FAR pthread_rwlock_t *rw_lock);
1006 int pthread_rwlock_init(FAR pthread_rwlock_t *rw_lock, FAR const pthread_rwlockattr_t *attr);
1020 int pthread_rwlock_timedrdlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime);
1027 int pthread_rwlock_timedwrlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime);
1056 
1061 #ifdef __cplusplus
1062 }
1063 #endif
1064 #endif /* __INCLUDE_PTHREAD_H */
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.
Definition: pthread.h:360
int pthread_setcancelstate(int state, FAR int *oldstate)
set cancelability state
Structure of pthread rwlock.
Definition: pthread.h:387
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.
Definition: pthread.h:283
struct pthread_region_s region[2]
Definition: pthread.h:271
Structure of pthread mutex configuration.
Definition: pthread.h:311
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
Definition: pthread.h:248
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_condattr_t
Definition: pthread.h:277
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
pthread_cond_t cv
Definition: pthread.h:389
int pthread_mutexattr_getrobust(FAR const pthread_mutexattr_t *attr, FAR int *robust)
get the mutex robust attribute
unsigned int num_readers
Definition: pthread.h:390
int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize)
set the stacksize attribute
POSIX-like scheduling parameter structure.
Definition: sched.h:115
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
void * address
Definition: pthread.h:258
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
bool write_in_progress
Definition: pthread.h:392
int pthread_condattr_destroy(FAR pthread_condattr_t *attr)
destroy the condition variable attributes object
pthread_startroutine_t pthread_func_t
Definition: pthread.h:251
POSIX operating system APIs.
Signal APIs.
int pthread_rwlock_timedwrlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime)
lock a read-write lock for writing
bool pthread_once_t
Definition: pthread.h:375
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.
Definition: pthread.h:266
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
unsigned int num_writers
Definition: pthread.h:391
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.
Definition: pthread.h:293
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_rwlockattr_t
Definition: pthread.h:397
int pthread_setspecific(pthread_key_t key, FAR const void *value)
thread-specific data management
uint8_t inheritsched
Definition: pthread.h:270
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.
Definition: pthread.h:369
Structure of generic semaphore.
Definition: semaphore.h:113
int pthread_key_t
Definition: pthread.h:247
pthread_addr_t(* pthread_startroutine_t)(pthread_addr_t)
Definition: pthread.h:250
FAR struct pthread_mutex_s * flink
Definition: pthread.h:316
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
unsigned int count
Definition: pthread.h:371
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
pthread_mutex_t lock
Definition: pthread.h:388
uint8_t policy
Definition: pthread.h:269
int pthread_rwlock_wrlock(FAR pthread_rwlock_t *lock)
lock a read-write lock object for writing
structure represents an elapsed time
Definition: time.h:152
uint32_t attributes
Definition: pthread.h:260
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
uint32_t size
Definition: pthread.h:259
uint32_t sigset_t
Definition: signal.h:214
int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
destroy a mutex
uint8_t flags
Definition: pthread.h:323
size_t stacksize
Definition: pthread.h:267
int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t startroutine, pthread_addr_t arg)
thread creation
int16_t priority
Definition: pthread.h:268
Structure of pthread region configuration.
Definition: pthread.h:257
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
pid_t pthread_t
Definition: pthread.h:275