pub unsafe extern "C" fn k_mutex_lock(
mutex: *mut k_mutex,
timeout: k_timeout_t,
) -> i32Expand description
@brief Lock a mutex.
This routine locks @a mutex. If the mutex is locked by another thread, the calling thread waits until the mutex becomes available or until a timeout occurs.
A thread is permitted to lock a mutex it has already locked. The operation completes immediately and the lock count is increased by 1.
Mutexes may not be locked in ISRs.
A mutex must not be freed, or have its memory reused, while it is locked or while threads are waiting on it. A mutex embedded in a dynamically allocated object must be unlocked before that object is released; otherwise the owning thread is left tracking a mutex in memory that no longer belongs to it.
@param mutex Address of the mutex. @param timeout Waiting period to lock the mutex, or one of the special values K_NO_WAIT and K_FOREVER.
@retval 0 Mutex locked. @retval -EBUSY Returned without waiting. @retval -EAGAIN Waiting period timed out.