Linux Kernel
3.7.1
|
#include <linux/list.h>
#include <linux/spinlock_types.h>
#include <linux/linkage.h>
#include <linux/lockdep.h>
#include <linux/atomic.h>
Go to the source code of this file.
Data Structures | |
struct | mutex |
struct | mutex_waiter |
Macros | |
#define | __DEBUG_MUTEX_INITIALIZER(lockname) |
#define | mutex_init(mutex) |
#define | __DEP_MAP_MUTEX_INITIALIZER(lockname) |
#define | __MUTEX_INITIALIZER(lockname) |
#define | DEFINE_MUTEX(mutexname) struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) |
#define | mutex_lock_nested(lock, subclass) mutex_lock(lock) |
#define | mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock) |
#define | mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock) |
#define | mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock) |
#define | arch_mutex_cpu_relax() cpu_relax() |
Functions | |
void | __mutex_init (struct mutex *lock, const char *name, struct lock_class_key *key) |
void | mutex_lock (struct mutex *lock) |
int __must_check | mutex_lock_interruptible (struct mutex *lock) |
int __must_check | mutex_lock_killable (struct mutex *lock) |
int | mutex_trylock (struct mutex *lock) |
void | mutex_unlock (struct mutex *lock) |
int | atomic_dec_and_mutex_lock (atomic_t *cnt, struct mutex *lock) |
#define __MUTEX_INITIALIZER | ( | lockname | ) |
#define DEFINE_MUTEX | ( | mutexname | ) | struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) |
#define mutex_init | ( | mutex | ) |
#define mutex_lock_interruptible_nested | ( | lock, | |
subclass | |||
) | mutex_lock_interruptible(lock) |
#define mutex_lock_killable_nested | ( | lock, | |
subclass | |||
) | mutex_lock_killable(lock) |
#define mutex_lock_nest_lock | ( | lock, | |
nest_lock | |||
) | mutex_lock(lock) |
#define mutex_lock_nested | ( | lock, | |
subclass | |||
) | mutex_lock(lock) |
mutex_lock - acquire the mutex : the mutex to be acquired
Lock the mutex exclusively for this task. If the mutex is not available right now, it will sleep until it can get it.
The mutex must later on be released by the same task that acquired it. Recursive locking is not allowed. The task may not exit without first unlocking the mutex. Also, kernel memory where the mutex resides mutex 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 CONFIG_DEBUG_MUTEXES .config option turns on debugging checks that will enforce the restrictions and will also do deadlock debugging. )
This function is similar to (but not equivalent to) down().
int __must_check mutex_lock_interruptible | ( | struct mutex * | lock | ) |
mutex_lock_interruptible - acquire the mutex, interruptible : the mutex to be acquired
Lock the mutex like mutex_lock(), and return 0 if the mutex has been acquired or sleep until the mutex becomes available. If a signal arrives while waiting for the lock then this function returns -EINTR.
This function is similar to (but not equivalent to) down_interruptible().
mutex_trylock - try to acquire the mutex, without waiting : the mutex to be acquired
Try to acquire the mutex atomically. Returns 1 if the mutex has been acquired successfully, and 0 on contention.
NOTE: this function follows the spin_trylock() convention, so it is negated from the down_trylock() return values! Be careful about this when converting semaphore users to mutexes.
This function must not be used in interrupt context. The mutex must be released by the same task that acquired it.