miosix::Mutex Class Reference
[Syncronization]
#include <sync.h>
List of all members.
Detailed Description
A mutex class with support for priority inheritance. If a thread tries to enter a critical section which is not free, it will be put to sleep and added to a queue of sleeping threads, ordered by priority. The thread that is into the critical section inherits the highest priority among the threads that are waiting if it is higher than its original priority.
This mutex is meant to be a static or global class. Dynamically creating a mutex with new or on the stack must be done with care, to avoid deleting a locked mutex, and to avoid situations where a thread tries to lock a deleted mutex.
Member Enumeration Documentation
Mutex options, passed to the constructor to set additional options.
The DEFAULT option indicates the default Mutex type.
- Enumerator:
-
DEFAULT |
Default mutex. |
RECURSIVE |
Mutex is recursive. |
Constructor & Destructor Documentation
miosix::Mutex::Mutex |
( |
Options |
opt = DEFAULT |
) |
|
Constructor, initializes the mutex.
Member Function Documentation
void miosix::Mutex::lock |
( |
|
) |
[inline] |
Locks the critical section. If the critical section is already locked, the thread will be queued in a wait list.
bool miosix::Mutex::try_lock |
( |
|
) |
[inline] |
Acquires the lock only if the critical section is not already locked by other threads. Attempting to lock again a recursive mutex will fail, and the mutex' lock count will not be incremented.
- Returns:
- true if the lock was acquired
void miosix::Mutex::unlock |
( |
|
) |
[inline] |
Unlocks the critical section.
The documentation for this class was generated from the following files:
- /Users/fede/Documents/Projects/ARM/miosix/miosix_np_2/miosix/kernel/sync.h
- /Users/fede/Documents/Projects/ARM/miosix/miosix_np_2/miosix/kernel/sync.cpp