Zephyr API 3.6.99
|
Macros | |
#define | SYS_MUTEX_DEFINE(name) |
Statically define and initialize a sys_mutex. | |
Functions | |
static void | sys_mutex_init (struct sys_mutex *mutex) |
Initialize a mutex. | |
static int | sys_mutex_lock (struct sys_mutex *mutex, k_timeout_t timeout) |
Lock a mutex. | |
static int | sys_mutex_unlock (struct sys_mutex *mutex) |
Unlock a mutex. | |
#define SYS_MUTEX_DEFINE | ( | name | ) |
#include <zephyr/sys/mutex.h>
Statically define and initialize a sys_mutex.
The mutex can be accessed outside the module where it is defined using:
Route this to memory domains using K_APP_DMEM().
name | Name of the mutex. |
|
inlinestatic |
#include <zephyr/sys/mutex.h>
Initialize a mutex.
This routine initializes a mutex object, prior to its first use.
Upon completion, the mutex is available and does not have an owner.
This routine is only necessary to call when userspace is disabled and the mutex was not created with SYS_MUTEX_DEFINE().
mutex | Address of the mutex. |
|
inlinestatic |
#include <zephyr/sys/mutex.h>
Lock a mutex.
This routine locks 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.
mutex | Address of the mutex, which may reside in user memory |
timeout | Waiting period to lock the mutex, or one of the special values K_NO_WAIT and K_FOREVER. |
0 | Mutex locked. |
-EBUSY | Returned without waiting. |
-EAGAIN | Waiting period timed out. |
-EACCES | Caller has no access to provided mutex address |
-EINVAL | Provided mutex not recognized by the kernel |
|
inlinestatic |
#include <zephyr/sys/mutex.h>
Unlock a mutex.
This routine unlocks mutex. The mutex must already be locked by the calling thread.
The mutex cannot be claimed by another thread until it has been unlocked by the calling thread as many times as it was previously locked by that thread.
mutex | Address of the mutex, which may reside in user memory |
0 | Mutex unlocked |
-EACCES | Caller has no access to provided mutex address |
-EINVAL | Provided mutex not recognized by the kernel or mutex wasn't locked |
-EPERM | Caller does not own the mutex |