Embedded Artistry Framework
Embedded Systems C++ Framework
Typedefs | Enumerations
embvm::mutex Namespace Reference

Mutex types and definitions. More...

Typedefs

using handle_t = uintptr_t
 Generic type for mutex handles. More...
 

Enumerations

enum  type : std::uint8_t { type::normal = 0, type::recursive, type::defaultType = recursive }
 Mutex types. More...
 
enum  mode : std::uint8_t { mode::none = 0, mode::priorityInherit, mode::protect, mode::defaultMode }
 Mutex operational modes. More...
 

Detailed Description

Mutex types and definitions.

Typedef Documentation

◆ handle_t

Generic type for mutex handles.

Enumeration Type Documentation

◆ mode

Mutex operational modes.

Mutexes can operate in various modes which affect thread scheduling. The Virtual RTOS utilizes three mode types:

  • none: scheduling is not impacted by a thread owning the mutex
  • priority inheritance: owning the mutex elevates the owning thread to the highest priority of all threads waiting on the mutex
  • protect: A thread owning a mutex will execute at the highest priority among all mutexes owned by a thread

The default operational mode is priority inheritance. Note that not all RTOSes may support the full range of modes. The program should fail to compile or run if an invalid mode is used.

Survey of OSes:

  • ThreadX uses "Inherit/No Inherit" mode
  • Pthread uses "protect, inherit, none" mode
Enumerator
none 
priorityInherit 

scheduling not impacted by owning the mutex

protect 

owning the mutex elevates you to the highest priority of all threads waiting on mutex

defaultMode 

execute at highest priority among all mutexes owned by a thread

◆ type

Mutex types.

Mutexes come in multiple flavors. The two variants that we utilize in the framework are "normal" mutexs and recursive mutexes.

Normal mutexes can only be locked once, even by the same thread. There is potential for a deadlock to occur if a thread holding a lock tries to lock again.

Recursive mutexes solve this deadlocking potential by allowing a mutex to be locked multiple times by the same thread. To relinquish a recursive mutex, it must be unlocked the same number of times that it was locked.

Enumerator
normal 

A normal mutex can only be locked once, even by the same thread.

recursive 

A recursive mutex can be locked multiple times by the same thread, but it must be unlocked the same number of times.

defaultType 

The default operational type for the Virtual RTOS mutexes is recursive.