The critical section code (critical sections), also known as the critical section (critical region), refers to the code segments that must be fully and continuously run and cannot be interrupted. A large number of critical code segments exist in the μC/OS-ⅲ system. Two methods are used to protect the critical segment code: Disable the interrupt and lock the scheduler. The code protection functions of the two critical segments are implemented by macro definition.
For the critical segment code accessed by both the interrupt handler and the task, you must use the managed interrupt method for protection. For the critical segment code accessed only by the task, you can also use locks to lock the Scheduler for protection.
At the same time, the μC/OS-ⅲ system also has the function of measuring the shutdown interruption time and the scheduler lock time. This function can be used to measure the closing and locking times of a single time or the total closing locks.
Critical segment code in μC/OS-ⅲ