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 (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 to understand exactly what an RTOS does at the hardware level: how a CPU saves and restores task state across an exception, 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. The context switch is this 16-register split.
Kernel: The piece of code responsible for switching the context, handling priorities, and saving/loadin registers. Runs on the Main Stack Pointer (MSP).
Task: The actual piece of code running on the CPU after a context switch. It runs on the Process Stack Pointer (PSP).
Each task gets its own 100-word stack. 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.