µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.
os::rtos::scheduler::critical_section Class Reference

Scheduler critical section RAII helper. More...

#include <cmsis-plus/rtos/os.h>

Public Member Functions

Constructors & Destructor
 critical_section ()
 Enter a critical section. More...
 
 ~critical_section ()
 Exit a critical section. More...
 

Detailed Description

Scheduler critical section RAII helper.

Use this class to define a critical section protected to scheduler switches. The beginning of the critical section is exactly the place where this class is instantiated (the constructor will lock the scheduler). The end of the critical section is the end of the surrounding block (the destructor will unlock the scheduler).

Note
Can be nested as many times as required without problems, only the outer call will unlock the scheduler.
Example
void
func(void)
{
// Do something
{
scheduler::critical_section scs; // Critical section begins here.
// Inside the critical section.
// No scheduler switches will happen here.
} // Critical section ends here.
// Do something else.
}

Definition at line 170 of file os-sched.h.

Constructor & Destructor Documentation

◆ critical_section()

os::rtos::scheduler::critical_section::critical_section ( )
inline

Enter a critical section.

Parameters
None.

Lock the scheduler and remember the initial scheduler state.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 911 of file os-sched.h.

◆ ~critical_section()

os::rtos::scheduler::critical_section::~critical_section ( )
inline

Exit a critical section.

Restore the initial scheduler state and possibly unlock the scheduler.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 927 of file os-sched.h.


The documentation for this class was generated from the following file: