4–5 Minute Detailed Architecture: RustOS (x86_64 Bare-Metal Microkernel)

Target Duration: ~3.5 to 5 minutes (~650–850 spoken words)
Goal: Deliver an end-to-end architectural explanation covering bootloader handoff, CPU control tables, memory management, preemptive context switching, and the filesystem interface.


🎙️ Spoken Script & Architectural Walkthrough

To explain the complete architecture of RustOS, I divide the system into four main stages: CPU bootstrapping and interrupt setup, physical and heap memory management, preemptive scheduling with synchronization, and the I/O and filesystem interface.


Stage 1: CPU Bootstrapping & Hardware Setup

The kernel boots on bare metal under x86_64 in a freestanding no_std environment, meaning there is no C runtime, no standard library, and no OS underneath.

Everything starts in kernel_main where I initialize the core CPU data structures in a strict order:

  1. Global Descriptor Table (GDT): Even though segmentation is mostly vestigial in 64-bit mode, the GDT is still required to set the 64-bit code segment and load a Task State Segment (TSS). The TSS holds an Interrupt Stack Table pointing to a dedicated emergency stack, ensuring that if a kernel stack overflows, the double fault handler runs on a clean stack rather than causing a fatal triple fault and system reset.
  2. Interrupt Descriptor Table (IDT): I register 256 interrupt descriptors for CPU exceptions—like breakpoint, double fault, and page fault—as well as external hardware interrupts.
  3. 8259 PIC Remapping: I remap hardware IRQs to interrupt vectors 32 through 47 to avoid conflicting with x86 CPU exception vectors (0–31). Once remapped, interrupts are safely enabled using the sti instruction.

(Hook: Deep dive into Topic 01: Boot, GDT & TSS and Topic 02: IDT & PIC)


Stage 2: Physical Memory & Dynamic Heap Allocation

Once hardware interrupts are ready, I initialize memory management using the memory mappings provided by the bootloader:

(Hook: Deep dive into Topic 03: 4-Level Paging and Topic 04: Heap & Allocators)


Stage 3: Round-Robin Preemptive Multitasking & Synchronization

With the heap active, I initialize preemptive multitasking:

(Hook: Deep dive into Topic 05: Multitasking & Mutex)


Stage 4: VGA Driver, Interactive Shell & In-Memory Filesystem

On top of this multitasking core, I implemented the driver and user-facing layer:

(Hook: Deep dive into Topic 06: VFS & Shell)