µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
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.
 
 ~critical_section ()
 Exit a critical section.
 

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.
}
Scheduler critical section RAII helper.
Definition os-sched.h:170

Definition at line 169 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: