FreeRTOS: POSIX
Return to main page ↑
pthread.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS POSIX V1.2.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
33 #ifndef _FREERTOS_POSIX_PTHREAD_H_
34 #define _FREERTOS_POSIX_PTHREAD_H_
35 
36 /* FreeRTOS+POSIX includes. POSIX states that this header shall make symbols
37  * defined in sched.h and time.h visible. */
38 #include "FreeRTOS_POSIX/sched.h"
39 #include "FreeRTOS_POSIX/time.h"
40 
45 #define PTHREAD_CREATE_DETACHED 0
46 #define PTHREAD_CREATE_JOINABLE 1
56 #define PTHREAD_BARRIER_SERIAL_THREAD ( -2 )
57 
62 #ifndef PTHREAD_MUTEX_NORMAL
63  #define PTHREAD_MUTEX_NORMAL 0
64 #endif
65 #ifndef PTHREAD_MUTEX_ERRORCHECK
66  #define PTHREAD_MUTEX_ERRORCHECK 1
67 #endif
68 #ifndef PTHREAD_MUTEX_RECURSIVE
69  #define PTHREAD_MUTEX_RECURSIVE 2
70 #endif
71 #ifndef PTHREAD_MUTEX_DEFAULT
72  #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
73 #endif
74 
86 #if posixconfigENABLE_PTHREAD_COND_T == 1
87  #define PTHREAD_COND_INITIALIZER FREERTOS_POSIX_COND_INITIALIZER
88 #endif
89 
90 #if posixconfigENABLE_PTHREAD_MUTEX_T == 1
91  #define PTHREAD_MUTEX_INITIALIZER FREERTOS_POSIX_MUTEX_INITIALIZER
92 #endif
93 
104 
113  int * detachstate );
114 
123  struct sched_param * param );
124 
132 int pthread_attr_getstacksize( const pthread_attr_t * attr,
133  size_t * stacksize );
134 
145 int pthread_attr_init( pthread_attr_t * attr );
146 
157  int detachstate );
158 
169  const struct sched_param * param );
170 
181  int policy );
182 
192  size_t stacksize );
193 
204 
223  const pthread_barrierattr_t * attr,
224  unsigned count );
225 
234 int pthread_barrier_wait( pthread_barrier_t * barrier );
235 
244 int pthread_create( pthread_t * thread,
245  const pthread_attr_t * attr,
246  void * ( *startroutine )( void * ),
247  void * arg );
248 
257 
266 
278  const pthread_condattr_t * attr );
279 
287 int pthread_cond_signal( pthread_cond_t * cond );
288 
301  pthread_mutex_t * mutex,
302  const struct timespec * abstime );
303 
312  pthread_mutex_t * mutex );
313 
322 int pthread_equal( pthread_t t1,
323  pthread_t t2 );
324 
332 void pthread_exit( void * value_ptr );
333 
343 int pthread_getschedparam( pthread_t thread,
344  int * policy,
345  struct sched_param * param );
346 
358 int pthread_join( pthread_t thread,
359  void ** retval );
360 
371 
382  const pthread_mutexattr_t * attr );
383 
395 int pthread_mutex_lock( pthread_mutex_t * mutex );
396 
410  const struct timespec * abstime );
411 
425 
436 
445 
454  int * type );
455 
467 
477  int type );
478 
486 pthread_t pthread_self( void );
487 
497 int pthread_setschedparam( pthread_t thread,
498  int policy,
499  const struct sched_param * param );
500 
501 #endif /* _FREERTOS_POSIX_PTHREAD_H_ */
int pthread_attr_destroy(pthread_attr_t *attr)
Destroy the thread attributes object.
Definition: FreeRTOS_POSIX_pthread.c:136
int pthread_cond_broadcast(pthread_cond_t *cond)
Broadcast a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:105
void pthread_exit(void *value_ptr)
Thread termination.
Definition: FreeRTOS_POSIX_pthread.c:393
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Unlock a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:276
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count)
Initialize a barrier object.
Definition: FreeRTOS_POSIX_pthread_barrier.c:70
Time types.
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
Get the mutex type attribute.
Definition: FreeRTOS_POSIX_pthread_mutex.c:330
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialize the mutex attributes object.
Definition: FreeRTOS_POSIX_pthread_mutex.c:342
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:112
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy condition variables.
Definition: FreeRTOS_POSIX_pthread_cond.c:141
PthreadMutexAttrType_t pthread_mutexattr_t
Used to identify a mutex attribute object.
Definition: types.h:145
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*startroutine)(void *), void *arg)
Thread creation.
Definition: FreeRTOS_POSIX_pthread.c:285
Scheduling parameters required for implementation of each supported scheduling policy.
Definition: sched.h:48
int pthread_attr_init(pthread_attr_t *attr)
Initialize the thread attributes object.
Definition: FreeRTOS_POSIX_pthread.c:188
PthreadMutexType_t pthread_mutex_t
Used for mutexes.
Definition: types.h:135
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Dynamic thread scheduling parameters access.
Definition: FreeRTOS_POSIX_pthread.c:487
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get detachstate attribute.
Definition: FreeRTOS_POSIX_pthread.c:145
int pthread_mutex_trylock(pthread_mutex_t *mutex)
Attempt to lock a mutex. Fail immediately if mutex is already locked.
Definition: FreeRTOS_POSIX_pthread_mutex.c:252
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Wait on a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:290
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
Wait on a condition with a timeout.
Definition: FreeRTOS_POSIX_pthread_cond.c:215
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
Get stacksize attribute.
Definition: FreeRTOS_POSIX_pthread.c:176
void * pthread_barrierattr_t
Used to define a barrier attributes object.
Definition: types.h:106
Execution scheduling.
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
Set schedparam attribute.
Definition: FreeRTOS_POSIX_pthread.c:220
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime)
Lock a mutex with timeout.
Definition: FreeRTOS_POSIX_pthread_mutex.c:177
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
Get schedparam attribute.
Definition: FreeRTOS_POSIX_pthread.c:164
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroy the mutex attributes object.
Definition: FreeRTOS_POSIX_pthread_mutex.c:321
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the mutex type attribute.
Definition: FreeRTOS_POSIX_pthread_mutex.c:351
int pthread_cond_signal(pthread_cond_t *cond)
Signal a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:182
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:170
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
Set the schedpolicy attribute.
Definition: FreeRTOS_POSIX_pthread.c:253
int pthread_equal(pthread_t t1, pthread_t t2)
Compare thread IDs.
Definition: FreeRTOS_POSIX_pthread.c:385
void * pthread_condattr_t
Used to identify a condition attribute object.
Definition: types.h:125
int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
Dynamic thread scheduling parameters access.
Definition: FreeRTOS_POSIX_pthread.c:370
pthread_t pthread_self(void)
Get the calling thread ID.
Definition: FreeRTOS_POSIX_pthread.c:478
int pthread_barrier_wait(pthread_barrier_t *barrier)
Synchronize at a barrier.
Definition: FreeRTOS_POSIX_pthread_barrier.c:120
PthreadBarrierType_t pthread_barrier_t
Used to identify a barrier.
Definition: types.h:99
PthreadCondType_t pthread_cond_t
Used for condition variables.
Definition: types.h:115
int pthread_mutex_destroy(pthread_mutex_t *mutex)
Destroy a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:97
represents an elapsed time
Definition: time.h:99
int pthread_join(pthread_t thread, void **retval)
Wait for thread termination.
Definition: FreeRTOS_POSIX_pthread.c:406
PthreadAttrType_t pthread_attr_t
Used to identify a thread attribute object.
Definition: types.h:89
int pthread_barrier_destroy(pthread_barrier_t *barrier)
Destroy a barrier object.
Definition: FreeRTOS_POSIX_pthread_barrier.c:57
void * pthread_t
Used to identify a thread.
Definition: types.h:155
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Initialize condition variables.
Definition: FreeRTOS_POSIX_pthread_cond.c:153
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set detachstate attribute.
Definition: FreeRTOS_POSIX_pthread.c:198
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Set stacksize attribute.
Definition: FreeRTOS_POSIX_pthread.c:265