Critical Sections
A critical section of code, also called a critical region, is code that needs to be treated indivisibly. There are many critical sections of code contained in µC/OS-III. If a critical section is accessible by an Interrupt Service Routine (ISR) and a task, then disabling interrupts is necessary to protect the critical region. If the critical section is only accessible by task level code, the critical section may be protected through the use of a preemption lock.
µC/OS-III will disable interrupts when accessing internal critical sections.
µC/OS-III uses µC/CPU macros for entering and leaving a critical section:
CPU_CRITICAL_ENTER() and
CPU_CRITICAL_EXIT()
These macros may be invoked by the application code. However, if you need to protect critical sections, consult Resource Management for additional options.