In this case we perform a critical piece of code, disabling all interrupts while a global shared flag is read.
During the critical section, no interrupts may occur.
Setup
Prerequisites
There are no special setup requirements for this use-case.
Use Case
Code
Copy-paste the following code to your user application:
if (is_ready == true) {
is_ready = false;
}
Workflow
- Enter a critical section to disable global interrupts.
- Note
- Critical sections may be nested if desired; if nested, global interrupts will only be re-enabled once the outer-most critical section has completed.
- Check a global shared flag and perform a response. This code may be any critical code that requires exclusive access to all resources without the possibility of interruption.
if (is_ready == true) {
is_ready = false;
}
- Exit the critical section to re-enable global interrupts.