FreeRTOS: POSIX
Return to main page ↑
semaphore.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_SEMAPHORE_H_
34 #define _FREERTOS_POSIX_SEMAPHORE_H_
35 
36 /* FreeRTOS+POSIX includes. */
37 #include "FreeRTOS_POSIX/time.h"
38 #include "FreeRTOS_POSIX_types.h"
39 
43 typedef PosixSemType_t sem_t;
44 
54 int sem_destroy( sem_t * sem );
55 
65 int sem_getvalue( sem_t * sem,
66  int * sval );
67 
84 int sem_init( sem_t * sem,
85  int pshared,
86  unsigned value );
87 
95 int sem_post( sem_t * sem );
96 
114 int sem_timedwait( sem_t * sem,
115  const struct timespec * abstime );
116 
129 int sem_trywait( sem_t * sem );
130 
141 int sem_wait( sem_t * sem );
142 
143 #endif /* ifndef _FREERTOS_POSIX_SEMAPHORE_H_ */
Time types.
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
Lock a semaphore with timeout.
Definition: FreeRTOS_POSIX_semaphore.c:129
int sem_wait(sem_t *sem)
Lock a semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:228
int sem_destroy(sem_t *sem)
Destroy an unnamed semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:45
int sem_init(sem_t *sem, int pshared, unsigned value)
Initialize an unnamed semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:74
int sem_getvalue(sem_t *sem, int *sval)
Get the value of a semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:57
PosixSemType_t sem_t
Semaphore type.
Definition: semaphore.h:43
int sem_post(sem_t *sem)
Unlock a semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:109
represents an elapsed time
Definition: time.h:99
int sem_trywait(sem_t *sem)
Lock a semaphore if available.
Definition: FreeRTOS_POSIX_semaphore.c:206