Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
mutex.h
Go to the documentation of this file.
1 
4 #ifndef __KERNEL_MUTEX_H__
5 #define __KERNEL_MUTEX_H__
6 
7 #include <stdbool.h>
8 
9 #include <common/list.h>
10 
11 struct mutex_attr {
12  int protocol;
13 };
14 
15 struct mutex {
16  int protocol;
17  struct thread_info *owner;
18  struct list_head wait_list;
19 };
20 
21 struct cond {
22  struct list_head task_wait_list;
23 };
24 
25 int __mutex_lock(struct mutex *mtx);
26 
32 void mutex_init(struct mutex *mtx);
33 
39 bool mutex_is_locked(struct mutex *mtx);
40 
46 int mutex_lock(struct mutex *mtx);
47 
53 int mutex_unlock(struct mutex *mtx);
54 
55 #endif
void mutex_init(struct mutex *mtx)
Initialize the mutex.
Definition: mutex.c:14
int mutex_lock(struct mutex *mtx)
Lock the mutex.
Definition: mutex.c:55
int mutex_unlock(struct mutex *mtx)
Unlock the mutex.
Definition: mutex.c:71
bool mutex_is_locked(struct mutex *mtx)
Check if the mutex is locked or not.
Definition: mutex.c:20
Definition: mutex.h:21
Definition: list.h:111
Definition: mutex.h:11
Definition: mutex.h:15
Definition: kernel.h:68