ARM Cortex M and RTOSs Are Meant for Each Other - nhivp/vnos GitHub Wiki
What is a RTOS?
- Multitasking
- RTOS is a software that manages the time of a CPU.
- Application is split into multiple tasks
- Tasks
- Each task is assigned a priority based on its importance.
- Manages its own ram, CPU registers, and stacks.
- Possibly manages I/O devices.
- Preemptive scheduling
Advantage of ARM Cortex-M for implementing a RTOS
- Privileged / non-privileged modes
- System code (ISRs, Some Tasks) runs in privileged mode
- Tasks run with limited privileges
- Mandatory NVIC
- Supports up to 256 exception/interrupt sources
- Each exception/interrupt can be assigned a priority
- Easy to enable/disable interrupts
- Dedicated stacks for ISRs
- Tasks use the PSP (Process Stack Pointer)
- ISRs use the MSP (Main Stack Pointer)
- Exception handler/Interrupts can be written in C
- Dedicated timer for RTOS Tick (SysTick)
- Dedicated context switch exception handler (PendSV)
- MPU
- Process separation
- Prevent tasks from corrupting stack or memory of other tasks
- Prevent unprivileged tasks from accessing peripherals
- Prevent execution out of RAM
- MPU registers loaded at context switch
Reference