Linux Kernel
3.7.1
|
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/debug_locks.h>
#include "mutex.h"
#include <asm/mutex.h>
Go to the source code of this file.
EXPORT_SYMBOL | ( | __mutex_init | ) |
EXPORT_SYMBOL | ( | mutex_lock | ) |
EXPORT_SYMBOL | ( | mutex_unlock | ) |
EXPORT_SYMBOL | ( | mutex_lock_interruptible | ) |
EXPORT_SYMBOL | ( | mutex_lock_killable | ) |
EXPORT_SYMBOL | ( | mutex_trylock | ) |
EXPORT_SYMBOL | ( | atomic_dec_and_mutex_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().
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.