|
PatchworkOS
|
Recursive Mutex. More...
Data Structures | |
| struct | mutex_t |
| Mutex structure. More... | |
Macros | |
| #define | MUTEX_SCOPE(mutex) |
| Acquires a mutex for the reminder of the current scope. | |
| #define | MUTEX_CREATE {.waitQueue = WAIT_QUEUE_CREATE, .owner = NULL, .depth = 0, .lock = LOCK_CREATE} |
| Create a mutex initializer. | |
Functions | |
| void | mutex_init (mutex_t *mtx) |
| Initializes a mutex. | |
| void | mutex_deinit (mutex_t *mtx) |
| Deinitializes a mutex. | |
| void | mutex_acquire (mutex_t *mtx) |
| Acquires a mutex, blocking until it is available. | |
| bool | mutex_acquire_timeout (mutex_t *mtx, clock_t timeout) |
| Acquires a mutex, blocking until it is available or the timeout is reached. | |
| void | mutex_release (mutex_t *mtx) |
| Releases a mutex. | |
| static void | mutex_cleanup (mutex_t **mtx) |
Recursive Mutex.
| #define MUTEX_CREATE {.waitQueue = WAIT_QUEUE_CREATE, .owner = NULL, .depth = 0, .lock = LOCK_CREATE} |
| #define MUTEX_SCOPE | ( | mutex | ) |
Acquires a mutex for the reminder of the current scope.
| mutex | Pointer to the mutex to acquire. |
| void mutex_acquire | ( | mutex_t * | mtx | ) |
Acquires a mutex, blocking until it is available.
If the mutex is already owned by the current thread, this function will return immediately.
| mtx | Pointer to the mutex to acquire. |
Definition at line 26 of file mutex.c.
References assert, CLOCKS_NEVER, and mutex_acquire_timeout().
Referenced by dentry_free(), vfs_link(), and vfs_remove().
Acquires a mutex, blocking until it is available or the timeout is reached.
If the mutex is already owned by the current thread, this function will return immediately.
| mtx | Pointer to the mutex to acquire. |
| timeout | Timeout in clock ticks or CLOCKS_NEVER to wait indefinitely. |
Definition at line 33 of file mutex.c.
References assert, CLOCKS_NEVER, CONFIG_MUTEX_MAX_SLOW_SPIN, mutex_t::depth, ERR, mutex_t::lock, lock_acquire(), lock_release(), NULL, mutex_t::owner, sched_thread(), timer_uptime(), WAIT_BLOCK_LOCK, WAIT_BLOCK_LOCK_TIMEOUT, and mutex_t::waitQueue.
Referenced by mutex_acquire().
|
inlinestatic |
Definition at line 89 of file mutex.h.
References mutex_release().
| void mutex_deinit | ( | mutex_t * | mtx | ) |
Deinitializes a mutex.
| mtx | Pointer to the mutex to deinitialize. |
Definition at line 20 of file mutex.c.
References assert, NULL, mutex_t::owner, wait_queue_deinit(), and mutex_t::waitQueue.
| void mutex_init | ( | mutex_t * | mtx | ) |
Initializes a mutex.
| mtx | Pointer to the mutex to initialize. |
Definition at line 12 of file mutex.c.
References mutex_t::depth, mutex_t::lock, lock_init(), NULL, mutex_t::owner, wait_queue_init(), and mutex_t::waitQueue.
Referenced by aml_init(), dentry_new(), and inode_new().
| void mutex_release | ( | mutex_t * | mtx | ) |
Releases a mutex.
The mutex must be owned by the current thread.
| mtx | Pointer to the mutex to release. |
Definition at line 103 of file mutex.c.
References assert, mutex_t::depth, EOK, mutex_t::lock, LOCK_SCOPE, NULL, mutex_t::owner, sched_thread_unsafe(), wait_unblock(), and mutex_t::waitQueue.
Referenced by dentry_free(), mutex_cleanup(), vfs_link(), and vfs_remove().