Skip to main content

Tag

Systems Programming

17 articles filed under Systems Programming, newest first.

All topics All articles

Articles tagged Systems Programming

Diagram of a shell REPL loop reading from the UART, parsing, executing built-in commands and printing back to the terminal

Chapter 13 · Operating Systems

Writing a Shell in C: A REPL Over the UART

Give PurgatoryOS a prompt. Add uart_getc and a line-discipline buffer, parse commands on top of Post 12's ramdisk, dispatch built-ins (ls, cat, echo, cd, pwd, help, clear), and load /bin/hello as a flat binary at a fixed address. This is the payoff post, where readers finally type into their own kernel.

49 min Intermediate

Diagram of a ramdisk filesystem tree with bin, docs and README nodes backed by a file table stored in the kernel heap

Chapter 12 · Operating Systems

Build a Simple Filesystem: Turning the Heap Into a Ramdisk

Build an in-memory tree filesystem for PurgatoryOS in no_std Rust using Box<Node>, BTreeMap<String, NodeId>, and Vec<u8> on top of Post 11's allocator. Add three new syscalls (open, read, close), a per-task file descriptor table, and a working VFS layer that the shell in Post 13 can type against.

35 min Intermediate

Diagram of a C kernel calling a Rust no_std allocator crate across the extern C FFI boundary, linked into a single kernel.elf

Chapter 11 · Operating Systems

Rust no_std Kernel Allocator: Bringing Rust Into a C Kernel

Carve the C heap allocator out of PurgatoryOS and replace it with a no_std Rust implementation wired in via extern C FFI. Set up aarch64-unknown-none-softfloat, build-std core + alloc, the GlobalAlloc trait, a spin-locked free list, and a Makefile that links libpurgatory_rs.a into the existing kernel.elf, without rewriting a single line of C above the allocator.

37 min Intermediate

Diagram of an EL0 user task issuing svc to cross the privilege boundary into the EL1 kernel, dispatching through a syscall table and returning with eret

Chapter 10 · Operating Systems

How System Calls Work: Drawing the Line Between User and Kernel

Drop your AArch64 tasks into EL0, trap into EL1 with the svc instruction, decode ESR_EL1 EC=0x15, dispatch through a syscall table, and return cleanly with eret. Four real syscalls (write, exit, getpid and yield) and the hardware-enforced privilege boundary that makes them possible.

37 min Intermediate

Diagram of two process control blocks exchanging CPU state through context_switch, with tasks A and B interleaving on a round-robin timeline

Chapter 9 · Operating Systems

Context Switching & Process Scheduling: Teaching the Kernel to Multitask

Build a round-robin task scheduler from scratch for your AArch64 bare-metal kernel. Implement the PCB, understand why only callee-saved registers need saving, write the context_switch assembly, and watch two tasks interleave on the UART, the moment your kernel becomes an actual operating system.

22 min Intermediate

Diagram of a kernel heap divided into used and free blocks with headers, linked into a free list traversed by kmalloc and kfree

Chapter 8 · Operating Systems

Kernel Heap Allocator in C: Teaching the Kernel to Manage Its Own Memory

Write a bump allocator and then a free-list allocator from scratch in C for your AArch64 bare-metal kernel. Learn block headers, first-fit search, coalescing, alignment, and why Rust's no_std offers a safer alternative. Visualize every allocation interactively.

25 min Intermediate

Diagram of an AArch64 exception vector table with a timer interrupt routed through the GICv2 to the CPU and the kernel's IRQ handler

Chapter 7 · Operating Systems

AArch64 Exceptions & Interrupts: Teaching Your Kernel to Listen

Build an AArch64 exception vector table from scratch, set up the GICv2 Generic Interrupt Controller on QEMU, and write a working ARM Generic Timer interrupt handler. Your kernel finally responds to the hardware.

29 min Intermediate

Diagram of an AArch64 virtual address walked through L0, L1 and L2 page tables to a physical 2 MB block of RAM

Chapter 6 · Operating Systems

AArch64 Virtual Memory & the MMU: Teaching the CPU to Lie

Master the AArch64 MMU on bare metal ARM. A deep dive into page table structures, translation levels (L0-L3), and configuring SCTLR_EL1, TCR_EL1, and MAIR_EL1 for kernel memory protection.

36 min Intermediate

Diagram of a CPU storing a character to the PL011 UART data register at 0x09000000 over MMIO, with the text appearing on a terminal

Chapter 4 · Operating Systems

PL011 UART Driver on QEMU: Your First Bare-Metal Kernel Output

Learn how to write a bare-metal C driver for the PL011 UART on AArch64. Master Memory-Mapped I/O (MMIO), the volatile keyword in C, and building a kprint function for QEMU virt without a standard library.

15 min Intermediate

Diagram of the ARM64 boot flow from the reset vector through exception levels EL2 to EL1, with the boot checklist ending at kernel_main

Chapter 3 · Operating Systems

The ARM64 Boot Process: From Reset Vector to kernel_main

Learn how to write an ARM64 bootloader stub in assembly. We cover AArch64 exception levels (EL2 to EL1), zeroing BSS, stack setup, and jumping to a C kernel_main on bare metal.

21 min Intermediate