Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
mutex.c File Reference
#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.

Functions

void __mutex_init (struct mutex *lock, const char *name, struct lock_class_key *key)
 
 EXPORT_SYMBOL (__mutex_init)
 
void __sched mutex_lock (struct mutex *lock)
 
 EXPORT_SYMBOL (mutex_lock)
 
void __sched mutex_unlock (struct mutex *lock)
 
 EXPORT_SYMBOL (mutex_unlock)
 
int __sched mutex_lock_interruptible (struct mutex *lock)
 
 EXPORT_SYMBOL (mutex_lock_interruptible)
 
int __sched mutex_lock_killable (struct mutex *lock)
 
 EXPORT_SYMBOL (mutex_lock_killable)
 
int __sched mutex_trylock (struct mutex *lock)
 
 EXPORT_SYMBOL (mutex_trylock)
 
int atomic_dec_and_mutex_lock (atomic_t *cnt, struct mutex *lock)
 
 EXPORT_SYMBOL (atomic_dec_and_mutex_lock)
 

Function Documentation

void __mutex_init ( struct mutex lock,
const char name,
struct lock_class_key key 
)

Definition at line 40 of file mutex.c.

int atomic_dec_and_mutex_lock ( atomic_t cnt,
struct mutex lock 
)

atomic_dec_and_mutex_lock - return holding mutex if we dec to 0 : the atomic which we are to dec : the mutex to return holding if we dec to 0

return true and hold lock if we dec to 0, return false otherwise

Definition at line 483 of file mutex.c.

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  )
void __sched mutex_lock ( struct 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().

Definition at line 83 of file mutex.c.

int __sched 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().

Definition at line 369 of file mutex.c.

int __sched mutex_lock_killable ( struct mutex lock)

Definition at line 384 of file mutex.c.

int __sched mutex_trylock ( struct mutex lock)

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.

Definition at line 464 of file mutex.c.

void __sched mutex_unlock ( struct mutex lock)

mutex_unlock - release the mutex : the mutex to be released

Unlock a mutex that has been locked by this task previously.

This function must not be used in interrupt context. Unlocking of a not locked mutex is not allowed.

This function is similar to (but not equivalent to) up().

Definition at line 110 of file mutex.c.