TizenRT Libs&Environment  v2.0 M2
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_* 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 /*
208  * Maximum values of pthread key operation
209  */
210 #define PTHREAD_KEYS_MAX CONFIG_NPTHREAD_KEYS
211 #define PTHREAD_DESTRUCTOR_ITERATIONS CONFIG_NPTHREAD_DESTRUCTOR_ITERATIONS
212 
213 /* Definitions to map some non-standard, BSD thread management interfaces to
214  * the non-standard Linux-like prctl() interface. Since these are simple
215  * mappings to prctl, they will return 0 on success and -1 on failure with the
216  * err number in errno. This is an inconsistency with the pthread interfaces.
217  */
218 
228 #define pthread_setname_np(thread, name) \
229  prctl((int)PR_SET_NAME, (char*)name, (int)thread)
230 
240 #define pthread_getname_np(thread, name) \
241  prctl((int)PR_GET_NAME, (char*)name, (int)thread)
242 
243 /********************************************************************************
244  * Global Type Declarations
245  ********************************************************************************/
246 
247 #ifdef __cplusplus
248 extern "C" {
249 #endif
250 
251 /* pthread-specific types */
252 
253 typedef unsigned int pthread_key_t;
254 typedef CODE void (*pthread_destructor_t)(void *arg);
255 typedef FAR void *pthread_addr_t;
256 
259 
265  void *address; /* start address of the region */
266  uint32_t size; /* size of the region in bytes */
267  uint32_t attributes; /* attributes of the region */
268 };
274  size_t stacksize; /* Size of the stack allocated for the pthread */
275  int16_t priority; /* Priority of the pthread */
276  uint8_t policy; /* Pthread scheduler policy */
277  uint8_t inheritsched; /* Inherit parent prio/policy? */
278  struct pthread_region_s region[2]; /* space for user-space region if MPU supported */
279 };
281 
282 typedef pid_t pthread_t;
283 
284 typedef int pthread_condattr_t;
285 
292 };
294 #define PTHREAD_COND_INITIALIZER { SEM_INITIALIZER(0) }
295 
301  uint8_t pshared:1; /* PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED */
302 #ifdef CONFIG_PRIORITY_INHERITANCE
303  uint8_t proto:2; /* See PTHREAD_PRIO_* definitions */
304 #endif
305 #ifdef CONFIG_PTHREAD_MUTEX_TYPES
306  uint8_t type:2; /* Type of the mutex. See PTHREAD_MUTEX_* definitions */
307 #endif
308 #if defined(CONFIG_PTHREAD_MUTEX_BOTH) || defined(CONFIG_PTHREAD_MUTEX_ROBUST)
309  uint8_t robust:1; /* PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST */
310 #endif
311 };
313 
319 
320 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
321  /* Supports a singly linked list */
322 
323  FAR struct pthread_mutex_s *flink;
324 #endif
325  /* Payload */
326 
327  sem_t sem; /* Semaphore underlying the implementation of the mutex */
328  int pid; /* ID of the holder of the mutex */
329 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
330  uint8_t flags; /* See _PTHREAD_MFLAGS_* */
331 #endif
332 #ifdef CONFIG_PTHREAD_MUTEX_TYPES
333  uint8_t type; /* Type of the mutex. See PTHREAD_MUTEX_* definitions */
334  int nlocks; /* The number of recursive locks held */
335 #endif
336 };
338 
339 #define __PTHREAD_MUTEX_T_DEFINED 1
340 
341 #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
342 #ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
343 #define __PTHREAD_MUTEX_DEFAULT_FLAGS 0
344 #else
345 #define __PTHREAD_MUTEX_DEFAULT_FLAGS _PTHREAD_MFLAGS_ROBUST
346 #endif
347 #endif
348 
349 #if defined(CONFIG_PTHREAD_MUTEX_TYPES) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
350 #define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1, \
351  __PTHREAD_MUTEX_DEFAULT_FLAGS, \
352  PTHREAD_MUTEX_DEFAULT, 0}
353 #elif defined(CONFIG_PTHREAD_MUTEX_TYPES)
354 #define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1, \
355  PTHREAD_MUTEX_DEFAULT, 0}
356 #elif !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
357 #define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1,\
358  __PTHREAD_MUTEX_DEFAULT_FLAGS}
359 #else
360 #define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1}
361 #endif
362 
368  int pshared;
369 };
371 
378  unsigned int count;
379 };
381 
382 typedef bool pthread_once_t;
383 
384 #ifdef CONFIG_PTHREAD_CLEANUP
385 /* This type describes the pthread cleanup callback (non-standard) */
386 
387 typedef CODE void (*pthread_cleanup_t)(FAR void *arg);
388 #endif
389 
397  unsigned int num_readers;
398  unsigned int num_writers;
400 };
401 
403 
405 
406 #define PTHREAD_RWLOCK_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, \
407  PTHREAD_COND_INITIALIZER, \
408  0, 0, false}
409 
410 /* Forware references */
411 
412 struct sched_param; /* Defined in sched.h */
413 
414 /********************************************************************************
415  * Global Variables
416  ********************************************************************************/
417 
418 /********************************************************************************
419  * Global Function Prototypes
420  ********************************************************************************/
421 
422 /* Initializes a thread attributes object (attr) with default values for all of
423  * the individual attributes used by a given implementation.
424  */
425 
426 /* To create a thread object and runnable thread, a routine must be specified
427  * as the new thread's start routine. An argument may be passed to this
428  * routine, as an untyped address; an untyped address may also be returned as
429  * the routine's value. An attributes object may be used to specify details
430  * about the kind of thread being created.
431  */
432 
441 int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t startroutine, pthread_addr_t arg);
442 
443 /* A thread object may be "detached" to specify that the return value and
444  * completion status will not be requested.
445  */
454 int pthread_detach(pthread_t thread);
455 
456 /* A thread may terminate it's own execution or the execution of another
457  * thread.
458  */
467 void pthread_exit(pthread_addr_t value) noreturn_function;
476 int pthread_cancel(pthread_t thread);
485 int pthread_setcancelstate(int state, FAR int *oldstate);
493 int pthread_setcanceltype(int type, FAR int *oldtype);
494 
502 void pthread_testcancel(void);
503 
504 /* A thread may set up cleanup functions to execut when the thread exits or is canceled. */
505 #ifdef CONFIG_PTHREAD_CLEANUP
506 void pthread_cleanup_pop(int execute);
507 void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg);
508 #endif
509 
510 /* A thread can await termination of another thread and retrieve the return
511  * value of the thread.
512  */
513 
522 int pthread_join(pthread_t thread, FAR pthread_addr_t *value);
523 
531 int pthread_tryjoin_np(pthread_t thread, FAR pthread_addr_t *pexit_value);
532 
533 /* A thread may tell the scheduler that its processor can be made available. */
542 void pthread_yield(void);
543 
544 /* A thread may obtain a copy of its own thread handle. */
553 #define pthread_self() ((pthread_t)getpid())
554 
555 /* Compare two thread IDs. */
564 #define pthread_equal(t1, t2) ((t1) == (t2))
565 
566 /* Thread scheduling parameters */
575 int pthread_getschedparam(pthread_t thread, FAR int *policy, FAR struct sched_param *param);
584 int pthread_setschedparam(pthread_t thread, int policy, FAR const struct sched_param *param);
592 int pthread_setschedprio(pthread_t thread, int prio);
593 
594 /* Thread-specific Data Interfaces */
603 int pthread_key_create(FAR pthread_key_t *key, CODE void (*destructor)(FAR void *));
612 int pthread_setspecific(pthread_key_t key, FAR const void *value);
621 void *pthread_getspecific(pthread_key_t key);
630 int pthread_key_delete(pthread_key_t key);
631 
632 /* The following routines create, delete, lock and unlock mutexes. */
633 
642 int pthread_mutex_init(FAR pthread_mutex_t *mutex, FAR const pthread_mutexattr_t *attr);
651 int pthread_mutex_destroy(FAR pthread_mutex_t *mutex);
660 int pthread_mutex_lock(FAR pthread_mutex_t *mutex);
669 int pthread_mutex_trylock(FAR pthread_mutex_t *mutex);
678 int pthread_mutex_unlock(FAR pthread_mutex_t *mutex);
679 
680 /* A thread can create and delete condition variables. */
689 int pthread_cond_init(FAR pthread_cond_t *cond, FAR const pthread_condattr_t *attr);
698 int pthread_cond_destroy(FAR pthread_cond_t *cond);
699 
700 /* A thread can signal to and broadcast on a condition variable. */
718 int pthread_cond_signal(FAR pthread_cond_t *cond);
719 
720 /* A thread can wait for a condition variable to be signalled or broadcast. */
729 int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex);
730 
731 /* A thread can perform a timed wait on a condition variable. */
740 int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex, FAR const struct timespec *abstime);
741 
742 /* Barriers */
760 int pthread_barrier_init(FAR pthread_barrier_t *barrier, FAR const pthread_barrierattr_t *attr, unsigned int count);
769 int pthread_barrier_wait(FAR pthread_barrier_t *barrier);
770 
771 /* Pthread initialization */
780 int pthread_once(FAR pthread_once_t *once_control, CODE void (*init_routine)(void));
781 
782 /* Pthread signal management APIs */
791 int pthread_kill(pthread_t thread, int sig);
800 int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset);
801 
812 int pthread_attr_init(FAR pthread_attr_t *attr);
813 
814 /* An attributes object can be deleted when it is no longer needed. */
815 
823 
824 /* Set or obtain the default scheduling algorithm */
825 
832 int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, int policy);
839 int pthread_attr_getschedpolicy(FAR const pthread_attr_t *attr, int *policy);
846 int pthread_attr_setschedparam(FAR pthread_attr_t *attr, FAR const struct sched_param *param);
853 int pthread_attr_getschedparam(FAR const pthread_attr_t *attr, FAR struct sched_param *param);
860 int pthread_attr_setinheritsched(FAR pthread_attr_t *attr, int inheritsched);
867 int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr, FAR int *inheritsched);
868 
869 /* Set or obtain the default stack size */
876 int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize);
877 
884 int pthread_attr_getstacksize(FAR const pthread_attr_t *attr, long *stackaddr);
885 
886 /* Create, operate on, and destroy mutex attributes. */
907 int pthread_mutexattr_getpshared(FAR const pthread_mutexattr_t *attr, FAR int *pshared);
914 int pthread_mutexattr_setpshared(FAR pthread_mutexattr_t *attr, int pshared);
921 int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
936  FAR int *protocol);
944  int protocol);
952  FAR int *robust);
960  int robust);
961 
962 /* Operations on condition variables */
969 int pthread_condattr_init(FAR pthread_condattr_t *attr);
976 int pthread_condattr_destroy(FAR pthread_condattr_t *attr);
977 
978 /* Barrier attributes */
999 int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared);
1006 int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared);
1007 
1008 /* Pthread rwlock */
1009 
1016 int pthread_rwlock_destroy(FAR pthread_rwlock_t *rw_lock);
1023 int pthread_rwlock_init(FAR pthread_rwlock_t *rw_lock, FAR const pthread_rwlockattr_t *attr);
1037 int pthread_rwlock_timedrdlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime);
1044 int pthread_rwlock_timedwrlock(FAR pthread_rwlock_t *lock, FAR const struct timespec *abstime);
1073 
1078 #ifdef __cplusplus
1079 }
1080 #endif
1081 #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:367
int pthread_setcancelstate(int state, FAR int *oldstate)
set cancelability state
Structure of pthread rwlock.
Definition: pthread.h:394
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:290
Structure of pthread mutex configuration.
Definition: pthread.h:318
int pthread_join(pthread_t thread, FAR pthread_addr_t *value)
wait for thread termination
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...
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:255
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:284
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:396
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:397
int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize)
set the stacksize attribute
POSIX-like scheduling parameter structure.
Definition: sched.h:111
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:265
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:399
int pthread_condattr_destroy(FAR pthread_condattr_t *attr)
destroy the condition variable attributes object
pthread_startroutine_t pthread_func_t
Definition: pthread.h:258
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:382
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:273
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:398
CODE void(* pthread_destructor_t)(void *arg)
Definition: pthread.h:254
int pthread_setcanceltype(int type, FAR int *oldtype)
set cancelability state
int pthread_key_delete(pthread_key_t key)
thread-specific data key deletion
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:300
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:404
int pthread_setspecific(pthread_key_t key, FAR const void *value)
thread-specific data management
uint8_t inheritsched
Definition: pthread.h:277
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:376
Structure of generic semaphore.
Definition: semaphore.h:113
pthread_addr_t(* pthread_startroutine_t)(pthread_addr_t)
Definition: pthread.h:257
FAR struct pthread_mutex_s * flink
Definition: pthread.h:323
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:378
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:395
void * pthread_getspecific(pthread_key_t key)
thread-specific data management
uint8_t policy
Definition: pthread.h:276
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:160
uint32_t attributes
Definition: pthread.h:267
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:266
uint32_t sigset_t
Definition: signal.h:270
int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
destroy a mutex
uint8_t flags
Definition: pthread.h:330
size_t stacksize
Definition: pthread.h:274
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:275
Structure of pthread region configuration.
Definition: pthread.h:264
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:282
unsigned int pthread_key_t
Definition: pthread.h:253