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

  1. 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.
  2. Since interrupts are disabled upon calling CPU_CRITICAL_ENTER() and are not re-enabled until after calling CPU_CRITICAL_EXIT(), interrupts are postponed while all critical sections have not completely exited.
  3. Critical sections can be nested any number of times as long as CPU_CFG_CRITICAL_METHOD is not configured as CPU_CRITICAL_METHOD_INT_DIS_EN, which would re-enable interrupts upon the first call to CPU_CRITICAL_EXIT(), not the last call.
  4. CPU_CRITICAL_EXIT() must always call CPU_CRITICAL_ENTER() at the start of critical section protection.
  5. 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();