CPU_CRITICAL_EXIT
Description
Exits critical sections, restoring previous interrupt status and/or enabling interrupts.
Files
Each specific processor’s/compiler’s cpu.h
Prototype
CPU_CRITICAL_EXIT();
Arguments
None.
Returned Value
None.
Required Configuration
None.
Notes / Warnings
CPU_CRITICAL_ENTER()/CPU_CRITICAL_EXIT()
should be used to protect critical sections of code from interrupted or concurrent access when no other protection mechanisms are available or appropriate. For example, system code that must be re-entrant but without use of a software lock should protect the code using CPU critical sections.- Since interrupts are disabled upon calling
CPU_CRITICAL_ENTER()
and are not re-enabled until after callingCPU_CRITICAL_EXIT()
, interrupts are postponed while all critical sections have not completely exited. - Critical sections can be nested any number of times as long as
CPU_CFG_CRITICAL_METHOD
is not configured asCPU_CRITICAL_METHOD_INT_DIS_EN
, which would re-enable interrupts upon the first call toCPU_CRITICAL_EXIT()
, not the last call. CPU_CRITICAL_EXIT()
must always callCPU_CRITICAL_ENTER()
at the start of critical section protection.- See notes for CPU_INT_DIS and CPU_INT_EN.
Example Usage
Listing - CPU_CRITICAL_EXIT() example usage
CPU_SR_ALLOC(); CPU_CRITICAL_ENTER(); : : /* Code protected by critical sections ... */ : /* ... from interrupts or concurrent access. */ : CPU_CRITICAL_EXIT();