Skip to content

CriticalSection Class Update (MERGE version - mbed-os-5.8) #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/reference/api/platform/CriticalSectionLock.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## CriticalSectionLock

The CriticalSectionLock class provides a mechanism to access a resource without interruption. With the `lock` API, you can enter critical section with interrupts disabled. The `unlock` API is the exit from critical section, and the destructor restores the state of interrupts upon exit. Nesting of critical section is supported, and the destructor enables interrupts only when you exit from the last nested critical section.
The CriticalSectionLock class provides a mechanism to access a resource without interruption. With the `CriticalSectionLock::enable` API, you can enter critical section with interrupts disabled. The `CriticalSectionLock::disable()` API is the exit from critical section, and the last exit call restores the state of interrupts.

CriticalSectionLock class is based on RAII approach. In other words, the constructor acquires the lock, and the destructor destroys it automatically when it is out of scope. We do not recommend you use CriticalSectionLock as global or a member of a class because you will enter critical section on object creation, and all interrupts will be disabled.

Mbed OS supports nesting of critical section, and the destructor enables interrupts only when you exit from the last nested critical section.

<span class="notes">**Note:** You must not use time-consuming operations, standard library and RTOS functions inside critical section.</span>

### CriticalSectionLock class reference
Expand Down