AWS IoT FreeRTOS+POSIX
semaphore.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_SEMAPHORE_H_
34 #define _FREERTOS_POSIX_SEMAPHORE_H_
35 
36 /* FreeRTOS+POSIX includes. */
37 #include "FreeRTOS_POSIX/time.h"
38 
42 typedef void * sem_t;
43 
53 int sem_destroy( sem_t * sem );
54 
64 int sem_getvalue( sem_t * sem,
65  int * sval );
66 
83 int sem_init( sem_t * sem,
84  int pshared,
85  unsigned value );
86 
94 int sem_post( sem_t * sem );
95 
113 int sem_timedwait( sem_t * sem,
114  const struct timespec * abstime );
115 
128 int sem_trywait( sem_t * sem );
129 
140 int sem_wait( sem_t * sem );
141 
142 #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:131
int sem_wait(sem_t *sem)
Lock a semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:207
int sem_destroy(sem_t *sem)
Destroy an unnamed semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:51
int sem_init(sem_t *sem, int pshared, unsigned value)
Initialize an unnamed semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:77
void * sem_t
Semaphore type.
Definition: semaphore.h:42
int sem_getvalue(sem_t *sem, int *sval)
Get the value of a semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:64
int sem_post(sem_t *sem)
Unlock a semaphore.
Definition: FreeRTOS_POSIX_semaphore.c:119
represents an elapsed time
Definition: time.h:78
int sem_trywait(sem_t *sem)
Lock a semaphore if available.
Definition: FreeRTOS_POSIX_semaphore.c:185