The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
mutex.h File Reference

Go to the source code of this file.

Data Structures

struct  mutex_t
 sleeping mutex for long critical sections in process context (filesystem and disk I/O). More...

Macros

#define MUTEX_INIT   {false, 0, {0}, {0, 0, 0}}

Functions

void mutex_init (mutex_t *mutex)
 initialize a mutex to the unlocked state.
void mutex_lock (mutex_t *mutex)
 acquire a mutex, sleeping until it is free.
void mutex_unlock (mutex_t *mutex)
 release a mutex held by the current process and wake one waiter.
bool mutex_held (const mutex_t *mutex)
 check whether the current process holds a mutex (for assertions).

Macro Definition Documentation

◆ MUTEX_INIT

#define MUTEX_INIT   {false, 0, {0}, {0, 0, 0}}

Function Documentation

◆ mutex_init()

void mutex_init ( mutex_t * mutex)

initialize a mutex to the unlocked state.

Parameters
mutexthe mutex to initialize.

◆ mutex_lock()

void mutex_lock ( mutex_t * mutex)

acquire a mutex, sleeping until it is free.

not recursive.

Parameters
mutexthe mutex to acquire.

◆ mutex_unlock()

void mutex_unlock ( mutex_t * mutex)

release a mutex held by the current process and wake one waiter.

Parameters
mutexthe mutex to release.

◆ mutex_held()

bool mutex_held ( const mutex_t * mutex)

check whether the current process holds a mutex (for assertions).

Parameters
mutexthe mutex to check.
Returns
true if held by the current process.