Mark3 Realtime Kernel
mutex.h File Reference

Mutual exclusion class declaration Resource locks are implemented using mutual exclusion semaphores (Mutex_t). Protected blocks can be placed around any resource that may only be accessed by one thread at a time. If additional threads attempt to access the protected resource, they will be placed in a wait queue until the resource becomes available. When the resource becomes available, the thread with the highest original priority claims the resource and is activated. Priority inheritance is included in the implementation to prevent priority inversion. Always ensure that you claim and release your mutex objects consistently, otherwise you may end up with a deadlock scenario that's hard to debug. More...

#include "kerneltypes.h"
#include "mark3cfg.h"
#include "blocking.h"

Go to the source code of this file.

Classes

class  Mark3::Mutex
 The Mutex Class. Class providing Mutual-exclusion locks, based on BlockingObject. More...
 

Namespaces

 Mark3
 

Detailed Description

Mutual exclusion class declaration Resource locks are implemented using mutual exclusion semaphores (Mutex_t). Protected blocks can be placed around any resource that may only be accessed by one thread at a time. If additional threads attempt to access the protected resource, they will be placed in a wait queue until the resource becomes available. When the resource becomes available, the thread with the highest original priority claims the resource and is activated. Priority inheritance is included in the implementation to prevent priority inversion. Always ensure that you claim and release your mutex objects consistently, otherwise you may end up with a deadlock scenario that's hard to debug.

Initializing

Initializing a mutex object by calling:

clMutex.Init();

Resource protection example

clMutex.Claim();
...
<resource protected block>
...
clMutex.Release();

Definition in file mutex.h.