The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
mutex.c File Reference
#include "kernel/sync/mutex.h"
#include "arch/arch.h"
#include "kernel/assert.h"
#include "kernel/process/process.h"

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

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.