Lazuli
Data Structures | Macros | Functions
mutex.h File Reference

Mutexes interface. More...

#include <stdint.h>
#include <Lazuli/common.h>
#include <Lazuli/list.h>

Go to the source code of this file.

Data Structures

struct  Lz_Mutex
 Represents a mutex. More...
 

Macros

#define LZ_MUTEX_INIT   { 0, LINKED_LIST_INIT }
 Define the value to initialize a Lz_Mutex in the unlocked state. More...
 
#define LZ_MUTEX_INIT_LOCKED   { 1, LINKED_LIST_INIT }
 Define the value to initialize a Lz_Mutex in the locked state. More...
 

Functions

void Lz_Mutex_Init (Lz_Mutex *const mutex)
 Initialize an already allocated Lz_Mutex. More...
 
void Lz_Mutex_InitLocked (Lz_Mutex *const mutex)
 Initialize an already allocated Lz_Mutex. More...
 
void Lz_Mutex_Lock (Lz_Mutex *const mutex)
 Lock the mutex and enter critical section. More...
 
void Lz_Mutex_Unlock (Lz_Mutex *const mutex)
 Unlock the mutex and leave critical section. More...
 

Detailed Description

Mutexes interface.

Describes the interface for mutexes. Mutexes in Lazuli are implemented as blocking.

Definition in file mutex.h.

Macro Definition Documentation

◆ LZ_MUTEX_INIT

#define LZ_MUTEX_INIT   { 0, LINKED_LIST_INIT }

Define the value to initialize a Lz_Mutex in the unlocked state.

This macro constant must be used to statically initialize a declared mutex.

Definition at line 39 of file mutex.h.

◆ LZ_MUTEX_INIT_LOCKED

#define LZ_MUTEX_INIT_LOCKED   { 1, LINKED_LIST_INIT }

Define the value to initialize a Lz_Mutex in the locked state.

This macro constant must be used to statically initialize a declared mutex.

Definition at line 47 of file mutex.h.

Function Documentation

◆ Lz_Mutex_Init()

void Lz_Mutex_Init ( Lz_Mutex *const  mutex)

Initialize an already allocated Lz_Mutex.

The mutex will be initialized in an unlocked state.

Parameters
mutexA pointer to the Lz_Mutex to initialize.
Note
The calling task will abort if configuration macro LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_MUTEXES is set to 1 and the parameter mutex is NULL.

Definition at line 61 of file mutex.c.

◆ Lz_Mutex_InitLocked()

void Lz_Mutex_InitLocked ( Lz_Mutex *const  mutex)

Initialize an already allocated Lz_Mutex.

The mutex will be initialized in a locked state.

Parameters
mutexA pointer to the Lz_Mutex to initialize.
Note
The calling task will abort if configuration macro LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_MUTEXES is set to 1 and the parameter mutex is NULL.

Definition at line 69 of file mutex.c.

◆ Lz_Mutex_Lock()

void Lz_Mutex_Lock ( Lz_Mutex *const  mutex)

Lock the mutex and enter critical section.

Parameters
mutexA pointer to the Lz_Mutex to lock.
Note
The calling task will abort if configuration macro LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_MUTEXES is set to 1 and the parameter mutex is NULL.

Definition at line 77 of file mutex.c.

◆ Lz_Mutex_Unlock()

void Lz_Mutex_Unlock ( Lz_Mutex *const  mutex)

Unlock the mutex and leave critical section.

Parameters
mutexA pointer to the Lz_Mutex to unlock.
Note
The calling task will abort if configuration macro LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_MUTEXES is set to 1 and the parameter mutex is NULL.

Definition at line 91 of file mutex.c.