|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Critical section demo: a data race without it and a race-free update with it. More...
Go to the source code of this file.
Classes | |
| class | Thread< _AccessMode > |
Enumerations | |
| enum | { THREADS_MAX = 8 , ITERATIONS_MAX = 1000 / THREADS_MAX , COUNTER_EXPECT = ITERATIONS_MAX * THREADS_MAX } |
Functions | |
| static void | UnsafeIncrement () |
| static void | IncrementWithoutCS (void *) |
| static void | IncrementWithCS (void *) |
| void | RunExample () |
Variables | |
| int32_t | g_Counter = 0 |
Critical section demo: a data race without it and a race-free update with it.
Definition in file critical_section/example.cpp.
| anonymous enum |
| Enumerator | |
|---|---|
| THREADS_MAX | |
| ITERATIONS_MAX | |
| COUNTER_EXPECT | |
Definition at line 33 of file critical_section/example.cpp.
|
static |
Definition at line 69 of file critical_section/example.cpp.
References ITERATIONS_MAX, and UnsafeIncrement().
Referenced by RunExample().
|
static |
Definition at line 60 of file critical_section/example.cpp.
References ITERATIONS_MAX, and UnsafeIncrement().
Referenced by RunExample().
| void RunExample | ( | void | ) |
Definition at line 93 of file critical_section/example.cpp.
References stk::Kernel< TMode, TSize, TStrategy, TPlatform >::AddTask(), COUNTER_EXPECT, g_Counter, bsp::Led::GREEN, IncrementWithCS(), IncrementWithoutCS(), bsp::Led::InitAll(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::Initialize(), Thread< _AccessMode >::m_func, bsp::Led::RED, bsp::Led::Set(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::Start(), and THREADS_MAX.
|
static |
Definition at line 43 of file critical_section/example.cpp.
References g_Counter.
Referenced by IncrementWithCS(), and IncrementWithoutCS().
| int32_t g_Counter = 0 |
Definition at line 41 of file critical_section/example.cpp.
Referenced by RunExample(), and UnsafeIncrement().