|
XenevaOS
|


Go to the source code of this file.
Classes | |
| struct | ww_class |
Macros | |
| #define | WW_MUTEX_BASE mutex |
| #define | ww_mutex_base_init(l, n, k) __mutex_init(l,n,k) |
| #define | ww_mutex_base_is_locked(b) mutex_is_locked((b)) |
| #define | __WW_CLASS_INITIALIZER(ww_class, _is_wait_die) |
| #define | DEFINE_WD_CLASS(classname) struct ww_class classname = __WW_CLASS_INITIALIZER(classname, 1) |
| #define | DEFINE_WW_CLASS(classname) struct ww_class classname = __WW_CLASS_INITIALIZER(classname, 0) |
Functions | |
| context_lock_struct (ww_mutex) | |
| context_lock_struct (ww_acquire_ctx) | |
| int | ww_mutex_lock (struct ww_mutex *lock, struct ww_acquire_ctx *ctx) __cond_acquires(0 |
| int lock | __must_hold (ctx) |
| int __must_check | ww_mutex_lock_interruptible (struct ww_mutex *lock, struct ww_acquire_ctx *ctx) __cond_acquires(0 |
| void | ww_mutex_unlock (struct ww_mutex *lock) __releases(lock) |
| int __must_check | ww_mutex_trylock (struct ww_mutex *lock, struct ww_acquire_ctx *ctx) __cond_acquires(true |
| #define __WW_CLASS_INITIALIZER | ( | ww_class, | |
| _is_wait_die | |||
| ) |
| #define DEFINE_WD_CLASS | ( | classname | ) | struct ww_class classname = __WW_CLASS_INITIALIZER(classname, 1) |
| #define DEFINE_WW_CLASS | ( | classname | ) | struct ww_class classname = __WW_CLASS_INITIALIZER(classname, 0) |
| #define WW_MUTEX_BASE mutex |
| #define ww_mutex_base_init | ( | l, | |
| n, | |||
| k | |||
| ) | __mutex_init(l,n,k) |
| #define ww_mutex_base_is_locked | ( | b | ) | mutex_is_locked((b)) |
| int __must_check lock __must_hold | ( | ctx | ) |
| context_lock_struct | ( | ww_acquire_ctx | ) |
| context_lock_struct | ( | ww_mutex | ) |
|
extern |
ww_mutex_lock - acquire the w/w mutex @lock: the mutex to be acquired @ctx: w/w acquire context, or NULL to acquire only a single lock.
Lock the w/w mutex exclusively for this task.
Deadlocks within a given w/w class of locks are detected and handled with the wait/die algorithm. If the lock isn't immediately available this function will either sleep until it is (wait case). Or it selects the current context for backing off by returning -EDEADLK (die case). Trying to acquire the same lock with the same context twice is also detected and signalled by returning -EALREADY. Returns 0 if the mutex was successfully acquired.
In the die case the caller must release all currently held w/w mutexes for the given context and then wait for this contending lock to be available by calling ww_mutex_lock_slow. Alternatively callers can opt to not acquire this lock and proceed with trying to acquire further w/w mutexes (e.g. when scanning through lru lists trying to free resources).
The mutex must later on be released by the same task that acquired it. The task may not exit without first unlocking the mutex. Also, kernel memory where the mutex resides must not be freed with the mutex still locked. The mutex must first be initialized (or statically defined) before it can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be of the same w/w lock class as was used to initialize the acquire context.
A mutex acquired with this function must be released with ww_mutex_unlock.
|
extern |
ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible @lock: the mutex to be acquired @ctx: w/w acquire context
Lock the w/w mutex exclusively for this task.
Deadlocks within a given w/w class of locks are detected and handled with the wait/die algorithm. If the lock isn't immediately available this function will either sleep until it is (wait case). Or it selects the current context for backing off by returning -EDEADLK (die case). Trying to acquire the same lock with the same context twice is also detected and signalled by returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a signal arrives while waiting for the lock then this function returns -EINTR.
In the die case the caller must release all currently held w/w mutexes for the given context and then wait for this contending lock to be available by calling ww_mutex_lock_slow_interruptible. Alternatively callers can opt to not acquire this lock and proceed with trying to acquire further w/w mutexes (e.g. when scanning through lru lists trying to free resources).
The mutex must later on be released by the same task that acquired it. The task may not exit without first unlocking the mutex. Also, kernel memory where the mutex resides must not be freed with the mutex still locked. The mutex must first be initialized (or statically defined) before it can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be of the same w/w lock class as was used to initialize the acquire context.
A mutex acquired with this function must be released with ww_mutex_unlock.
|
extern |
|
extern |