Example:
Code: Select all
worddef exclusive async <isr> critical {
enter:
Disable_IRQ();
leave:
enable_IRQ();
async_enter:
disable_IRQ_fromISR();
async_leave:
enable_IRQ_fromISR();
}
critical int i = 0;
critical void signal(void) {
...
}
async <isr> void my_isr_function(void) {
critical {
i++;
signal();
}
}
void signal_handler(void) {
int local_i;
critical {
local_i = i--;
}
use(local_i);
}
Critical functions
- Functions that can only be called from within a critical section.
- Critical functions can only call critical or pure/const functions.
Critical variables
- Critical variables can only be accessed from within a critical block or by critical functions.
Giovanni