Skip to main content.
Navigation:
DENX
>
Training2
>
LddMutex
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
Training2
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
Training2 Home
Changes
Index
Search
Go
List of pages in Training2
Search
%SECTION0{name=LddMutex}% Mutexes * [[http://koti.mbnet.fi/niclasw/MutexSemaphore.html][semaphore vs mutex]] * [[http://lwn.net/Articles/273731/][semaphores not obsolete after all]] * mutexes [[http://lwn.net/Articles/167034/][lwn article]] * binary semaphore: locked or unlocked * used for protecting critical paths * restrictions: * one task can hold mutex at a time * only task which locks can unlock again * no recursive/multiple locking/unlocking * can't be used in interrupt context (hard or soft) * Advantages (over semaphores): * Plattform independant * faster than semphores (smaller!) * code may sleep * =DEBUG_MUTEXES= allows effective debugging * Disadvantages * only binary (no counting) ---++API: Kernel Mutexes _initalize:_ <verbatim> #include <linux/mutex.h> </verbatim> <verbatim> DEFINE_MUTEX(name); </verbatim> _at runtime:_ <verbatim> mutex_init(struct mutex *lock); </verbatim> _locking:_ <verbatim> void mutex_lock(struct mutex *lock); int mutex_lock_interruptible(struct mutex *lock); int mutex_trylock(struct mutex *lock); </verbatim> _unlocking:_ <verbatim> void mutex_unlock(struct mutex *lock); </verbatim> _testing state:_ <verbatim> int mutex_is_locked(struct mutex *lock); </verbatim>
5.7.4.1. Atomic operations
1. Denx Training Topics
5.7.4.3. Spinlocks
Prev
Home
Next