dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_mutex.h
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  */
25 
26 
27 #ifndef PIOS_MUTEX_H_
28 #define PIOS_MUTEX_H_
29 
30 #define PIOS_MUTEX_TIMEOUT_MAX 0xffffffff
31 
32 #include <stdint.h>
33 #include <stdbool.h>
34 
35 struct pios_mutex;
37 
38 /*
39  * The following functions implement the concept of a non-recursive mutex usable
40  * with PIOS_INCLUDE_CHIBIOS.
41  *
42  * Note that this is not the same as:
43  * - binary semaphore
44  * - semaphore
45  * - recursive mutex
46  *
47  * see FreeRTOS documentation for details: http://www.freertos.org/a00113.html
48  * see ChibiOS documentation for details: http://chibios.sourceforge.net/html/group__synchronization.html
49  */
50 
51 struct pios_mutex *PIOS_Mutex_Create(void);
52 bool PIOS_Mutex_Lock(struct pios_mutex *mtx, uint32_t timeout_ms);
53 bool PIOS_Mutex_Unlock(struct pios_mutex *mtx);
54 
55 /*
56  * The following functions implement the concept of a recursive mutex usable
57  * with PIOS_INCLUDE_CHIBIOS.
58  *
59  * Note that this is not the same as:
60  * - binary semaphore
61  * - semaphore
62  * - non-recursive mutex
63  *
64  * Note that this implementation doesn't prevent priority inversion.
65  *
66  * see FreeRTOS documentation for details: http://www.freertos.org/a00113.html
67  * see ChibiOS documentation for details: http://chibios.sourceforge.net/html/group__synchronization.html
68  */
69 
71 bool PIOS_Recursive_Mutex_Lock(struct pios_recursive_mutex *mtx, uint32_t timeout_ms);
73 
74 #endif /* PIOS_MUTEX_H_ */
75 
bool PIOS_Mutex_Unlock(struct pios_mutex *mtx)
Definition: pios_mutex.c:104
struct pios_mutex * PIOS_Mutex_Create(void)
Definition: pios_mutex.c:43
struct pios_recursive_mutex * PIOS_Recursive_Mutex_Create(void)
Definition: pios_mutex.c:115
bool PIOS_Recursive_Mutex_Lock(struct pios_recursive_mutex *mtx, uint32_t timeout_ms)
Definition: pios_mutex.c:139
bool PIOS_Recursive_Mutex_Unlock(struct pios_recursive_mutex *mtx)
Definition: pios_mutex.c:144
bool PIOS_Mutex_Lock(struct pios_mutex *mtx, uint32_t timeout_ms)
Definition: pios_mutex.c:66