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 __KERNEL_SEMAPHORE_H__
5 #define __KERNEL_SEMAPHORE_H__
6 
7 #include <stdint.h>
8 
9 #include <common/list.h>
10 
11 struct semaphore {
12  int32_t count;
13  struct list_head wait_list;
14 };
15 
22 void sema_init(struct semaphore *sem, int val);
23 
29 int down(struct semaphore *sem);
30 
38 int down_trylock(struct semaphore *sem);
39 
45 int up(struct semaphore *sem);
46 
47 #endif
int up(struct semaphore *sem)
Increase the number of the semaphore.
Definition: semaphore.c:63
int down(struct semaphore *sem)
Decrease the number of the semaphore.
Definition: semaphore.c:23
void sema_init(struct semaphore *sem, int val)
Initialize the semaphore.
Definition: semaphore.c:17
int down_trylock(struct semaphore *sem)
The same as down(), except that if the decrement cannot be immediately performed, then call returns a...
Definition: semaphore.c:43
Definition: list.h:111
Definition: semaphore.h:11