Lazuli
Loading...
Searching...
No Matches
mutex.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-only
3 * This file is part of Lazuli.
4 */
5
15#ifndef LAZULI_MUTEX_H
16#define LAZULI_MUTEX_H
17
18#include <stdint.h>
19
20#include <Lazuli/common.h>
21#include <Lazuli/list.h>
22
24
28typedef struct {
29 volatile uint8_t lock;
32
39#define LZ_MUTEX_INIT { 0, LINKED_LIST_INIT }
40
47#define LZ_MUTEX_INIT_LOCKED { 1, LINKED_LIST_INIT }
48
59void
60Lz_Mutex_Init(Lz_Mutex * const mutex);
61
72void
73Lz_Mutex_InitLocked(Lz_Mutex * const mutex);
74
84void
85Lz_Mutex_Lock(Lz_Mutex * const mutex);
86
96void
97Lz_Mutex_Unlock(Lz_Mutex * const mutex);
98
100
101#endif /* LAZULI_MUTEX_H */
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
Definition stdint.h:89
Basic type definitions and useful macros.
#define _EXTERN_C_DECL_BEGIN
Open C++ header file declarations.
Definition common.h:39
#define _EXTERN_C_DECL_END
Close C++ header file declarations.
Definition common.h:44
Doubly linked lists interface.
void Lz_Mutex_Unlock(Lz_Mutex *const mutex)
Unlock the mutex and leave critical section.
Definition mutex.c:92
void Lz_Mutex_InitLocked(Lz_Mutex *const mutex)
Initialize an already allocated Lz_Mutex.
Definition mutex.c:70
void Lz_Mutex_Init(Lz_Mutex *const mutex)
Initialize an already allocated Lz_Mutex.
Definition mutex.c:62
void Lz_Mutex_Lock(Lz_Mutex *const mutex)
Lock the mutex and enter critical section.
Definition mutex.c:78
Represents the main container for doubly linked elements.
Definition list.h:36
Represents a mutex.
Definition mutex.h:28
volatile uint8_t lock
The mutex lock
Definition mutex.h:29
Lz_LinkedList waitingTasks
The list of tasks waiting for that mutex.
Definition mutex.h:30