diff --git a/core/include/mutex.h b/core/include/mutex.h index d4eb46415f..c6655d15dc 100644 --- a/core/include/mutex.h +++ b/core/include/mutex.h @@ -253,6 +253,17 @@ static inline void mutex_init(mutex_t *mutex) mutex->queue.next = NULL; } +/** + * @brief Initializes a mutex object in a locked state. + * @details For initialization of variables use MUTEX_INIT_LOCKED instead. + * Only use the function call for dynamically allocated mutexes. + * @param[out] mutex pre-allocated mutex structure, must not be NULL. + */ +static inline void mutex_init_locked(mutex_t *mutex) +{ + *mutex = (mutex_t)MUTEX_INIT_LOCKED; +} + /** * @brief Initialize a mutex cancellation structure * @param mutex The mutex that the calling thread wants to lock