Amazon FreeRTOS: POSIX
Return to main page ↑
pthread.h
Go to the documentation of this file.
1 /*
2  * Amazon FreeRTOS POSIX V1.1.0
3  * Copyright (C) 2019 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_ */
pthread_mutexattr_gettype
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
Get the mutex type attribute.
Definition: FreeRTOS_POSIX_pthread_mutex.c:330
pthread_barrier_destroy
int pthread_barrier_destroy(pthread_barrier_t *barrier)
Destroy a barrier object.
Definition: FreeRTOS_POSIX_pthread_barrier.c:57
pthread_barrierattr_t
void * pthread_barrierattr_t
Used to define a barrier attributes object.
Definition: types.h:106
pthread_cond_init
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Initialize condition variables.
Definition: FreeRTOS_POSIX_pthread_cond.c:153
pthread_create
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*startroutine)(void *), void *arg)
Thread creation.
Definition: FreeRTOS_POSIX_pthread.c:285
pthread_attr_setstacksize
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Set stacksize attribute.
Definition: FreeRTOS_POSIX_pthread.c:265
pthread_setschedparam
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Dynamic thread scheduling parameters access.
Definition: FreeRTOS_POSIX_pthread.c:487
pthread_condattr_t
void * pthread_condattr_t
Used to identify a condition attribute object.
Definition: types.h:125
pthread_cond_broadcast
int pthread_cond_broadcast(pthread_cond_t *cond)
Broadcast a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:105
pthread_attr_init
int pthread_attr_init(pthread_attr_t *attr)
Initialize the thread attributes object.
Definition: FreeRTOS_POSIX_pthread.c:188
pthread_mutexattr_init
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialize the mutex attributes object.
Definition: FreeRTOS_POSIX_pthread_mutex.c:342
pthread_mutex_trylock
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
pthread_barrier_t
PthreadBarrierType_t pthread_barrier_t
Used to identify a barrier.
Definition: types.h:99
pthread_mutex_unlock
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Unlock a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:276
pthread_cond_destroy
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy condition variables.
Definition: FreeRTOS_POSIX_pthread_cond.c:141
pthread_cond_t
PthreadCondType_t pthread_cond_t
Used for condition variables.
Definition: types.h:115
sched.h
Execution scheduling.
pthread_cond_timedwait
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
pthread_mutex_init
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:112
pthread_attr_setschedparam
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
Set schedparam attribute.
Definition: FreeRTOS_POSIX_pthread.c:220
pthread_attr_getdetachstate
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get detachstate attribute.
Definition: FreeRTOS_POSIX_pthread.c:145
sched_param
Scheduling parameters required for implementation of each supported scheduling policy.
Definition: sched.h:48
pthread_mutexattr_destroy
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroy the mutex attributes object.
Definition: FreeRTOS_POSIX_pthread_mutex.c:321
pthread_t
void * pthread_t
Used to identify a thread.
Definition: types.h:155
pthread_mutex_timedlock
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime)
Lock a mutex with timeout.
Definition: FreeRTOS_POSIX_pthread_mutex.c:177
pthread_cond_signal
int pthread_cond_signal(pthread_cond_t *cond)
Signal a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:182
pthread_attr_getstacksize
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
Get stacksize attribute.
Definition: FreeRTOS_POSIX_pthread.c:176
pthread_attr_t
PthreadAttrType_t pthread_attr_t
Used to identify a thread attribute object.
Definition: types.h:89
time.h
Time types.
pthread_attr_getschedparam
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
Get schedparam attribute.
Definition: FreeRTOS_POSIX_pthread.c:164
pthread_cond_wait
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Wait on a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:281
pthread_barrier_wait
int pthread_barrier_wait(pthread_barrier_t *barrier)
Synchronize at a barrier.
Definition: FreeRTOS_POSIX_pthread_barrier.c:120
pthread_mutex_destroy
int pthread_mutex_destroy(pthread_mutex_t *mutex)
Destroy a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:97
pthread_getschedparam
int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
Dynamic thread scheduling parameters access.
Definition: FreeRTOS_POSIX_pthread.c:370
pthread_equal
int pthread_equal(pthread_t t1, pthread_t t2)
Compare thread IDs.
Definition: FreeRTOS_POSIX_pthread.c:385
pthread_mutex_t
PthreadMutexType_t pthread_mutex_t
Used for mutexes.
Definition: types.h:135
pthread_mutexattr_settype
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the mutex type attribute.
Definition: FreeRTOS_POSIX_pthread_mutex.c:351
pthread_mutexattr_t
PthreadMutexAttrType_t pthread_mutexattr_t
Used to identify a mutex attribute object.
Definition: types.h:145
pthread_mutex_lock
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:170
pthread_attr_setschedpolicy
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
Set the schedpolicy attribute.
Definition: FreeRTOS_POSIX_pthread.c:253
timespec
represents an elapsed time
Definition: time.h:79
pthread_join
int pthread_join(pthread_t thread, void **retval)
Wait for thread termination.
Definition: FreeRTOS_POSIX_pthread.c:406
pthread_self
pthread_t pthread_self(void)
Get the calling thread ID.
Definition: FreeRTOS_POSIX_pthread.c:478
pthread_attr_setdetachstate
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set detachstate attribute.
Definition: FreeRTOS_POSIX_pthread.c:198
pthread_exit
void pthread_exit(void *value_ptr)
Thread termination.
Definition: FreeRTOS_POSIX_pthread.c:393
pthread_barrier_init
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
pthread_attr_destroy
int pthread_attr_destroy(pthread_attr_t *attr)
Destroy the thread attributes object.
Definition: FreeRTOS_POSIX_pthread.c:136