...
µC/OS-III uses this technique (as do most, if not all, kernels) to access certain internal variables and data structures, ensuring that these variables and data structures are manipulated atomically. However, disabling and enabling interrupts are actually CPU-related functions rather than OS-related functions and functions in CPU-specific files are provided to accomplish this (see the cpu.h
file of the processor being used). The services provided in the CPU module are called µC/CPU. Each different target CPU architecture has its own set of µC/CPU-related files.
Code Block | ||||
---|---|---|---|---|
| ||||
void YourFunction (void) { CPU_SR_ALLOC(); (1) CPU_CRITICAL_ENTER(); (2) Access the resource; (3) CPU_CRITICAL_EXIT(); (4) } |
...