Skip to content

Commit 46ecf82

Browse files
committed
core/mutex: add mutex_init_locked()
1 parent 2734366 commit 46ecf82

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/include/mutex.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,17 @@ static inline void mutex_init(mutex_t *mutex)
253253
mutex->queue.next = NULL;
254254
}
255255

256+
/**
257+
* @brief Initializes a mutex object in a locked state.
258+
* @details For initialization of variables use MUTEX_INIT_LOCKED instead.
259+
* Only use the function call for dynamically allocated mutexes.
260+
* @param[out] mutex pre-allocated mutex structure, must not be NULL.
261+
*/
262+
static inline void mutex_init_locked(mutex_t *mutex)
263+
{
264+
*mutex = (mutex_t)MUTEX_INIT_LOCKED;
265+
}
266+
256267
/**
257268
* @brief Initialize a mutex cancellation structure
258269
* @param mutex The mutex that the calling thread wants to lock

0 commit comments

Comments
 (0)