153#if defined(DOXYGEN) || defined(MODULE_CORE_MUTEX_PRIORITY_INHERITANCE) \
154 || defined(MODULE_CORE_MUTEX_DEBUG)
166#if defined(DOXYGEN) || defined(MODULE_CORE_MUTEX_DEBUG)
176#if defined(DOXYGEN) || defined(MODULE_CORE_MUTEX_PRIORITY_INHERITANCE)
224# define MUTEX_INIT { .queue = { .next = NULL } }
229# define MUTEX_INIT_LOCKED { .queue = { .next = MUTEX_LOCKED } }
231# define MUTEX_INIT {}
232# define MUTEX_INIT_LOCKED { { MUTEX_LOCKED } }
240#define MUTEX_LOCKED ((list_node_t *)-1)
319 volatile uintptr_t *lock = (
void *)&mutex->
queue.
next;
369#if (MAXTHREADS > 1) || DOXYGEN
Platform-independent access to architecture details.
int16_t kernel_pid_t
Unique process identifier.
void mutex_unlock(mutex_t *mutex)
Unlocks the mutex.
void mutex_cancel(mutex_cancel_t *mc)
Cancels a call to mutex_lock_cancelable.
static mutex_cancel_t mutex_cancel_init(mutex_t *mutex)
Initialize a mutex cancellation structure.
int mutex_lock_cancelable(mutex_cancel_t *mc)
Locks a mutex, blocking.
static void mutex_init_locked(mutex_t *mutex)
Initializes a mutex object in a locked state.
#define MUTEX_INIT_LOCKED
Static initializer for mutex_t with a locked mutex.
static void mutex_init(mutex_t *mutex)
Initializes a mutex object.
void mutex_unlock_and_sleep(mutex_t *mutex)
Unlocks the mutex and sends the current thread to sleep.
static void mutex_lock(mutex_t *mutex)
Locks a mutex, blocking.
static int mutex_trylock(mutex_t *mutex)
Tries to get a mutex, non-blocking.
bool mutex_lock_internal(mutex_t *mutex, bool block)
Internal function implementing mutex_lock and mutex_trylock.
static thread_t * thread_get_active(void)
Returns a pointer to the Thread Control Block of the currently running thread.
uintptr_t uinttxtptr_t
Pointer type to point anywhere in the .text section.
Common macros and compiler attributes/pragmas configuration.
thread_t holds thread's context data.
struct list_node * next
pointer to next list entry
A cancellation structure for use with mutex_lock_cancelable and mutex_cancel.
thread_t * thread
The thread trying to lock the mutex.
uint8_t cancelled
Flag whether the mutex has been cancelled.
mutex_t * mutex
The mutex to lock.
uint8_t owner_original_priority
Original priority of the owner.
kernel_pid_t owner
The current owner of the mutex or NULL
list_node_t queue
The process waiting queue of the mutex.
uinttxtptr_t owner_calling_pc
Program counter of the call to mutex_lock that most recently acquired this mutex.
Provides utility functions for event handler threads.