Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
semaphore.h
Go to the documentation of this file.
1 
4 #ifndef __SEMAPHORE_H__
5 #define __SEMAPHORE_H__
6 
7 #include <stdint.h>
8 
9 #define __SIZEOF_SEM_T 12 /* sizeof(struct semaphore) */
10 
11 typedef union {
12  char __size[__SIZEOF_SEM_T];
13  uint32_t __align;
14 } sem_t;
15 
23 int sem_init(sem_t *sem, int pshared, unsigned int value);
24 
30 int sem_destroy(sem_t *sem);
31 
37 int sem_post(sem_t *sem);
38 
46 int sem_trywait(sem_t *sem);
47 
55 int sem_wait(sem_t *sem);
56 
63 int sem_getvalue(sem_t *sem, int *sval);
64 
65 #endif
int sem_post(sem_t *sem)
Increase the value of the semaphore.
Definition: semaphore.c:107
int sem_trywait(sem_t *sem)
The same as sem_wait(), except that if the decrement cannot be immediately performed,...
Definition: semaphore.c:112
int sem_init(sem_t *sem, int pshared, unsigned int value)
Initialize the semaphore.
Definition: semaphore.c:89
int sem_destroy(sem_t *sem)
Destroy the semaphore.
Definition: semaphore.c:98
int sem_getvalue(sem_t *sem, int *sval)
Get the value of the semaphore.
Definition: semaphore.c:122
int sem_wait(sem_t *sem)
Decrement the value of the semaphore. If the semaphore currently has the value zero,...
Definition: semaphore.c:117
Definition: semaphore.h:11