Lazuli
Functions
mutex.c File Reference

Mutex implementation. More...

#include <Lazuli/config.h>
#include <Lazuli/mutex.h>
#include <Lazuli/sys/arch/arch.h>
#include <Lazuli/sys/memory.h>
#include <Lazuli/sys/scheduler.h>
#include <Lazuli/sys/task.h>

Go to the source code of this file.

Functions

static void InitMutex (Lz_Mutex *const mutex, const Lz_Mutex *const initValue)
 Initialize a mutex in a given state. More...
 
static void WaitMutex (Lz_Mutex *const mutex)
 Set the task to wait for a given mutex to be unlocked. More...
 
User API
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

Mutex implementation.

This file describes the implementation of mutexes. Mutexes in Lazuli are implemented as blocking.

Definition in file mutex.c.

Function Documentation

◆ InitMutex()

static void InitMutex ( Lz_Mutex *const  mutex,
const Lz_Mutex *const  initValue 
)
static

Initialize a mutex in a given state.

Parameters
mutexA pointer to the mutex to initialize.
initValueA valid pointer to a mutex in the desired state.

Definition at line 30 of file mutex.c.

◆ WaitMutex()

static void WaitMutex ( Lz_Mutex *const  mutex)
static

Set the task to wait for a given mutex to be unlocked.

Parameters
mutexa valid pointer to the mutex to wait.

Definition at line 47 of file mutex.c.

◆ 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.