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 #include <time.h>
9 
10 #define __SIZEOF_SEM_T 12 /* sizeof(struct semaphore) */
11 
12 typedef union {
13  char __size[__SIZEOF_SEM_T];
14  uint32_t __align;
15 } sem_t;
16 
24 int sem_init(sem_t *sem, int pshared, unsigned int value);
25 
31 int sem_destroy(sem_t *sem);
32 
38 int sem_post(sem_t *sem);
39 
47 int sem_trywait(sem_t *sem);
48 
56 int sem_wait(sem_t *sem);
57 
64 int sem_timedwait(sem_t *sem, const struct timespec *abstime);
65 
72 int sem_getvalue(sem_t *sem, int *sval);
73 
74 #endif
Definition: time.h:16
int sem_post(sem_t *sem)
Increase the value of the semaphore.
Definition: semaphore.c:112
int sem_trywait(sem_t *sem)
The same as sem_wait(), except that if the decrement cannot be immediately performed,...
Definition: semaphore.c:122
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:152
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
Decrement the semaphore or timeout at abstime.
Definition: semaphore.c:142
int sem_wait(sem_t *sem)
Decrement the value of the semaphore. If the semaphore currently has the value zero,...
Definition: semaphore.c:132
Definition: semaphore.h:12