Platform: ARM Cortex-M4 MSP432E401Y
Toolchain: Keil MDK v5, ARMCLANG v6.23
Language: C + ARM Thumb Assembly
A preemptive real-time operating system built from scratch on bare metal. No HAL. No FreeRTOS. No vendor RTOS libraries. Every component from the context switcher to the scheduler to the allocator to the synchronisation primitives, was written by hand and verified against the ARM architecture reference manual and the TI chip datasheet.
The goal was not to ship a product. The goal was to understand exactly what an RTOS does at the hardware level: how a CPU saves and restores task state across an exception boundary, how a scheduler makes decisions, what priority inheritance actually means in silicon, and how memory allocation works when you control every byte.

The foundation of any RTOS is the context switch is the mechanism that lets multiple tasks share a single CPU.
On ARM Cortex-M4, three hardware exceptions make this possible. SysTick fires periodically as the kernel time base. PendSV is a software-triggered exception that performs the actual register swap. SVC launches the first task by tricking the CPU into an exception return.
The CPU automatically saves R0–R3, R12, LR, PC, and xPSR on any exception entry. The PendSV handler manually saves and restores R4–R11. That 16-register split is the entire context switch.
Each task gets its own 100-word stack. The kernel runs on the Main Stack Pointer. Tasks run on the Process Stack Pointer. On first launch, Create_Task pre-fills a fake 16-word stack frame for each task. So, the first EXC_RETURN pops the frame and jumps directly into the task function.