-
Notifications
You must be signed in to change notification settings - Fork 178
Critical Section doc update #298
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
AnotherButler
merged 7 commits into
ARMmbed:new_engine
from
deepikabhavnani:CriticalSectionLock
Oct 30, 2017
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d1c1ade
Critical Section doc update
38c98e9
Copy edit CriticalSectionLock.md
655c655
Changed example repo
807375e
Make minor capitalization change
8bead55
Added RAII approach and scope description
72310c3
Copy edit CriticalSectionLock.md
6ac407f
Change passive to active voice
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
## CriticalSectionLock | ||
|
||
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 state of interrupts is restored upon exit. Nesting of critical section is supported, and interrupts are enabled only when we exit from last nested critical section. | ||
|
||
CriticalSectionLock class is based on RAII approach i.e. lock is acquired in constructor and destroyed automatically when out of scope as part of destructor. Usage of CriticalSectionLock as global or member of class is not recommended, as you will enter critical section on object creation and all interrupts will be disabled. | ||
|
||
|
||
<span class="notes">**Note:** You must not use time consuming operations, standard library and RTOS functions inside critical section.</span> | ||
|
||
## CriticalSectionLock class reference | ||
|
||
[](https://os.mbed.com/docs/v5.6/mbed-os-api-doxy/classmbed_1_1_critical_section_lock.html) | ||
|
||
## CriticalSectionLock example | ||
|
||
Here is an example that demonstrates a race condition issue and how CriticalSectionLock helps resolves it. | ||
|
||
[](https://os.mbed.com/teams/mbed_example/code/mbed-os-example-critical-section/file/a88acbffd78b/main.cpp) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to remove mentions the
lock
andunlock
since these aren't RAII and may be deprecated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will keep them in 5.6 version as they are relevant. Hopefully we would deprecate by 5.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good