Project

General

Profile

Feature #1940

Updated by Vadim Mutilin over 9 years ago

You should not acquire or release the same mutex twice in the same process. All locked mutexes should be unlocked at finalization. 

 *Description* 

 There are several things you should watch for: 
 # *Double-locking.* Mutex-type object provides exclusive access to sections of executable code. Thus retrying to acquire the current mutex will inevitably lead to a deadlock-situation. Deadlocks should be avoided, hence no double locks should take place. 
 # *Releasing an unlocked mutex.* 
 # *Leaving a mutex locked* at finalization. 

 Mutex is a special case of semaphore, restricted with just one possible requestor. However, it has its own wrapping functions. To initialize a mutex, macros are often used: DECLARE_MUTEX(name) and DECLARE_MUTEX_LOCKED(name). Locking is provided via mutex_lock(), mutex_trylock() and mutex_lock_interruptible() functions; unlocking--via mutex_unlock(). 

 *Links* 
 Sample bugfixes "4a349aa":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=4a349aa, "a9e7fb5":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=a9e7fb5, "d47b389":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=d47b389, "c1c7415":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=c1c7415, "8a9f335":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=8a9f335, "723342c":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=723342c 


Back