AWS IoT FreeRTOS+POSIX
pthread.h
Go to the documentation of this file.
1 /*
2  * Amazon FreeRTOS+POSIX V1.0.0
3  * Copyright (C) 2018 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
55 #define PTHREAD_BARRIER_SERIAL_THREAD ( -2 )
56 
61 #ifndef PTHREAD_MUTEX_NORMAL
62  #define PTHREAD_MUTEX_NORMAL 0
63 #endif
64 #ifndef PTHREAD_MUTEX_ERRORCHECK
65  #define PTHREAD_MUTEX_ERRORCHECK 1
66 #endif
67 #ifndef PTHREAD_MUTEX_RECURSIVE
68  #define PTHREAD_MUTEX_RECURSIVE 2
69 #endif
70 #ifndef PTHREAD_MUTEX_DEFAULT
71  #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
72 #endif
73 
79 #define PTHREAD_COND_INITIALIZER FREERTOS_POSIX_COND_INITIALIZER
81 #if posixconfigENABLE_PTHREAD_MUTEX_T == 1
82 
86  #define PTHREAD_MUTEX_INITIALIZER FREERTOS_POSIX_MUTEX_INITIALIZER
87 #endif
88 
99 
108  int * detachstate );
109 
118  struct sched_param * param );
119 
127 int pthread_attr_getstacksize( const pthread_attr_t * attr,
128  size_t * stacksize );
129 
141 int pthread_attr_init( pthread_attr_t * attr );
142 
152  int detachstate );
153 
164  const struct sched_param * param );
165 
175  size_t stacksize );
176 
187 
205  const pthread_barrierattr_t * attr,
206  unsigned count );
207 
216 int pthread_barrier_wait( pthread_barrier_t * barrier );
217 
228 int pthread_create( pthread_t * thread,
229  const pthread_attr_t * attr,
230  void *( *startroutine )( void * ),
231  void * arg );
232 
241 
250 
262  const pthread_condattr_t * attr );
263 
271 int pthread_cond_signal( pthread_cond_t * cond );
272 
284  pthread_mutex_t * mutex,
285  const struct timespec * abstime );
286 
295  pthread_mutex_t * mutex );
296 
305 int pthread_equal( pthread_t t1,
306  pthread_t t2 );
307 
315 void pthread_exit( void * value_ptr );
316 
326 int pthread_getschedparam( pthread_t thread,
327  int * policy,
328  struct sched_param * param );
329 
340 int pthread_join( pthread_t thread,
341  void ** retval );
342 
353 
364  const pthread_mutexattr_t * attr );
365 
375 int pthread_mutex_lock( pthread_mutex_t * mutex );
376 
389  const struct timespec * abstime );
390 
402 
412 
421 
430  int * type );
431 
443 
453  int type );
454 
462 pthread_t pthread_self( void );
463 
473 int pthread_setschedparam( pthread_t thread,
474  int policy,
475  const struct sched_param * param );
476 
477 #endif /* _FREERTOS_POSIX_PTHREAD_H_ */
int pthread_attr_destroy(pthread_attr_t *attr)
Destroy the thread attributes object.
Definition: FreeRTOS_POSIX_pthread.c:131
void * pthread_barrier_t
Used to identify a barrier.
Definition: types.h:82
int pthread_cond_broadcast(pthread_cond_t *cond)
Broadcast a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:82
void pthread_exit(void *value_ptr)
Thread termination.
Definition: FreeRTOS_POSIX_pthread.c:381
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Unlock a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:272
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:83
Time types.
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
Get the mutex type attribute.
Definition: FreeRTOS_POSIX_pthread_mutex.c:320
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialize the mutex attributes object.
Definition: FreeRTOS_POSIX_pthread_mutex.c:332
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:113
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy condition variables.
Definition: FreeRTOS_POSIX_pthread_cond.c:111
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*startroutine)(void *), void *arg)
Thread creation.
Definition: FreeRTOS_POSIX_pthread.c:279
Scheduling parameters required for implementation of each supported scheduling policy.
Definition: sched.h:47
int pthread_attr_init(pthread_attr_t *attr)
Initialize the thread attributes object.
Definition: FreeRTOS_POSIX_pthread.c:180
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Dynamic thread scheduling parameters access.
Definition: FreeRTOS_POSIX_pthread.c:475
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get detachstate attribute.
Definition: FreeRTOS_POSIX_pthread.c:144
void * pthread_cond_t
Used for condition variables. Enabled/disabled by posixconfigENABLE_PTHREAD_COND_T.
Definition: types.h:94
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:248
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Wait on a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:246
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:192
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
Get stacksize attribute.
Definition: FreeRTOS_POSIX_pthread.c:168
void * pthread_mutexattr_t
Used to identify a mutex attribute object. Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEXATTR_T...
Definition: types.h:118
void * pthread_attr_t
Used to identify a thread attribute object. Enabled/disabled by posixconfigENABLE_PTHREAD_ATTR_T.
Definition: types.h:76
Execution scheduling.
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
Set schedparam attribute.
Definition: FreeRTOS_POSIX_pthread.c:228
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime)
Lock a mutex with timeout.
Definition: FreeRTOS_POSIX_pthread_mutex.c:183
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
Get schedparam attribute.
Definition: FreeRTOS_POSIX_pthread.c:156
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroy the mutex attributes object.
Definition: FreeRTOS_POSIX_pthread_mutex.c:310
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the mutex type attribute.
Definition: FreeRTOS_POSIX_pthread_mutex.c:360
void * pthread_barrierattr_t
Used to define a barrier attributes object.
Definition: types.h:87
int pthread_cond_signal(pthread_cond_t *cond)
Signal a condition.
Definition: FreeRTOS_POSIX_pthread_cond.c:159
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock a mutex.
Definition: FreeRTOS_POSIX_pthread_mutex.c:176
int pthread_equal(pthread_t t1, pthread_t t2)
Compare thread IDs.
Definition: FreeRTOS_POSIX_pthread.c:373
int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
Dynamic thread scheduling parameters access.
Definition: FreeRTOS_POSIX_pthread.c:359
pthread_t pthread_self(void)
Get the calling thread ID.
Definition: FreeRTOS_POSIX_pthread.c:466
int pthread_barrier_wait(pthread_barrier_t *barrier)
Synchronize at a barrier.
Definition: FreeRTOS_POSIX_pthread_barrier.c:152
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:78
int pthread_join(pthread_t thread, void **retval)
Wait for thread termination.
Definition: FreeRTOS_POSIX_pthread.c:394
void * pthread_mutex_t
Used for mutexes. Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEX_T.
Definition: types.h:110
int pthread_barrier_destroy(pthread_barrier_t *barrier)
Destroy a barrier object.
Definition: FreeRTOS_POSIX_pthread_barrier.c:67
void * pthread_condattr_t
Used to identify a condition attribute object. Enabled/disabled by posixconfigENABLE_PTHREAD_CONDATTR...
Definition: types.h:102
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Initialize condition variables.
Definition: FreeRTOS_POSIX_pthread_cond.c:125
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set detachstate attribute.
Definition: FreeRTOS_POSIX_pthread.c:208
void * pthread_t
Used to identify a thread. Enabled/disabled by posixconfigENABLE_PTHREAD_T.
Definition: types.h:126
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Set stacksize attribute.
Definition: FreeRTOS_POSIX_pthread.c:259