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 void __mutex_init(struct mutex *mtx);
26 void thread_inherit_priority(struct mutex *mutex);
27 void thread_reset_inherited_priority(struct mutex *mutex);
28 
34 void mutex_init(struct mutex *mtx);
35 
41 bool mutex_is_locked(struct mutex *mtx);
42 
49 int mutex_trylock(struct mutex *mtx);
50 
56 int mutex_lock(struct mutex *mtx);
57 
63 int mutex_unlock(struct mutex *mtx);
64 
65 #endif
int mutex_trylock(struct mutex *mtx)
Lock the mutex. If the mutex is currently locked then the function shall return immediately.
Definition: mutex.c:36
void mutex_init(struct mutex *mtx)
Initialize the mutex.
Definition: mutex.c:21
int mutex_lock(struct mutex *mtx)
Lock the mutex.
Definition: mutex.c:59
int mutex_unlock(struct mutex *mtx)
Unlock the mutex.
Definition: mutex.c:84
bool mutex_is_locked(struct mutex *mtx)
Check if the mutex is locked or not.
Definition: mutex.c:27
Definition: mutex.h:21
Definition: list.h:111
Definition: mutex.h:11
Definition: mutex.h:15
Definition: kernel.h:71