68typedef struct kos_mutex {
83#define MUTEX_TYPE_NORMAL 0
84#define MUTEX_TYPE_OLDNORMAL 1
85#define MUTEX_TYPE_ERRORCHECK 2
86#define MUTEX_TYPE_RECURSIVE 3
89#define MUTEX_TYPE_DEFAULT MUTEX_TYPE_NORMAL
93#define MUTEX_INITIALIZER { MUTEX_TYPE_NORMAL, 0, NULL, 0 }
96#define ERRORCHECK_MUTEX_INITIALIZER { MUTEX_TYPE_ERRORCHECK, 0, NULL, 0 }
99#define RECURSIVE_MUTEX_INITIALIZER { MUTEX_TYPE_RECURSIVE, 0, NULL, 0 }
282static inline void __mutex_scoped_cleanup(
mutex_t **m) {
287#define ___mutex_lock_scoped(m, l) \
288 mutex_t *__scoped_mutex_##l __attribute__((cleanup(__mutex_scoped_cleanup))) = mutex_lock(m) ? NULL : (m)
290#define __mutex_lock_scoped(m, l) ___mutex_lock_scoped(m, l)
301#define mutex_lock_scoped(m) __mutex_lock_scoped((m), __LINE__)
Definitions for builtin attributes and compiler directives.
#define __depr(m)
Mark something as deprecated, with an informative message.
Definition cdefs.h:119
int mutex_is_locked(mutex_t *m)
Check if a mutex is locked.
int mutex_lock(mutex_t *m)
Lock a mutex.
int mutex_trylock(mutex_t *m)
Attempt to lock a mutex.
mutex_t * mutex_create(void) __depr("Use mutex_init or an initializer.")
Allocate a new mutex.
int mutex_lock_irqsafe(mutex_t *m)
Lock a mutex.
int mutex_unlock_as_thread(mutex_t *m, kthread_t *thd)
Unlock a mutex under another thread's authority.
int mutex_init(mutex_t *m, int mtype)
Initialize a new mutex.
int mutex_unlock(mutex_t *m)
Unlock a mutex.
int mutex_destroy(mutex_t *m)
Destroy a mutex.
int mutex_lock_timed(mutex_t *m, int timeout)
Lock a mutex (with a timeout).
Structure describing one running thread.
Definition thread.h:169
Mutual exclusion lock type.
Definition mutex.h:68
int count
Definition mutex.h:72
int dynamic
Definition mutex.h:70
kthread_t * holder
Definition mutex.h:71
int type
Definition mutex.h:69