Writing an OS Kernel from Scratch – Part 26: User-Mode Display Server and Client — A True Graphics System Architecture

dean
Writing an OS Kernel from Scratch – Part 26: User-Mode Display Server and Client — A True Graphics System Architecture “An in-kernel Display Server is controllable but violates the microkernel philosophy; a real graphics system should be in userspace! Today, we move the Display Server and Client entirely to userspace, communicating via Unix domain sockets!”... » read more

#233 Conntrack: High-Performance Connection Tracking and NAT Implementation

dean
#233 Conntrack: High-Performance Connection Tracking and NAT Implementation Preface In the previous two articles, we thoroughly understood Netfilter’s HOOK mechanism (Article 231) and iptables’ rule table-chain system (Article 232). However, there’s one system hiding between them, omnipresent yet not yet detailed — Connection Tracking (conntrack). Conntrack is the cornerstone of Linux stateful firewalls. It’s because... » read more

Writing an OS Kernel from Scratch | #345: USB Protocol — From HID to High-Speed Devices

dean
Writing an OS Kernel from Scratch | #345: USB Protocol — From HID to High-Speed Devices Abstract: USB is essentially the “universal serial bus” for all peripherals, but many only know “plug and play.” This article takes you from physical layer topology, transfer types, xHCI controller, to practical lsusb usage, thoroughly understanding USB’s design philosophy... » read more

Writing an OS Kernel from Scratch – Part 6: First Look at Multitasking — From Single-Core Loops to Process Switching

dean
Writing an OS Kernel from Scratch – Part 6: First Look at Multitasking — From Single-Core Loops to Process Switching “A kernel that can only do one thing? That’s a bare-metal program. A real OS must be able to ‘simultaneously’ do multiple things!” In the previous five posts, we completed kernel boot, entering protected mode,... » read more

Writing an OS Kernel from Scratch – Part 15: Slab Allocator — Efficiently Managing Kernel Small Objects

dean
Writing an OS Kernel from Scratch – Part 15: Slab Allocator — Efficiently Managing Kernel Small Objects “The Buddy system is great at allocating large memory blocks, but what about the kernel’s frequent 32-byte, 128-byte small object allocations? Today, we implement the Slab allocator, making kernel memory allocation lightning fast!” In the previous post, we... » read more

A05 — Use-After-Free: The Problem of Accessing Freed Memory

dean
A05 — Use-After-Free: The Problem of Accessing Freed Memory Key insight: Continuing to use a freed memory block is like continuing to build a house on land you’ve already sold — sooner or later someone will come to tear it down. What is Use-After-Free Use-After-Free (UAF) refers to accessing memory that has already been freed... » read more

Long Article 104: Memory Management – Virtual Part I: In-Depth Page Table Operations and Virtual Memory Areas (VMA)

dean
Long Article 104: Memory Management – Virtual Part I: In-Depth Page Table Operations and Virtual Memory Areas (VMA) Analysis “Virtual memory is the cornerstone of modern operating systems, and VMA is the ‘map’ of the process address space. This article dives deep into x86 page table structures and VMA design principles, comparing Linux implementation details... » read more

A01 — The Internals of malloc: How brk and mmap Work Together

dean
A01 — The Internals of malloc: How brk and mmap Work Together Key Insight: Every block of memory you allocate with malloc is backed by the system making allocation decisions on your behalf. malloc is Not a System Call malloc is a glibc (ptmalloc) library function, not a system call. Two paths for malloc: 1.... » read more

Long Article 106: Memory Management — Advanced: Deep Dive into Copy-on-Write, Swapping, and NUMA Optimization

dean
# Long Article 106: Memory Management — Advanced: Deep Dive into Copy-on-Write, Swapping, and NUMA Optimization “When physical memory is insufficient, how does the OS handle it gracefully? This article covers CoW, Swapping, and NUMA optimization.” Introduction Three advanced features for memory pressure: CoW: Share pages on fork, copy only on write Swapping: Move inactive... » read more

Writing an OS Kernel from Scratch | VFS — The Virtual File System: How Linux’s “Everything is a File” Works

dean
Writing an OS Kernel from Scratch | VFS — The Virtual File System: How Linux’s “Everything is a File” Works You use cat /proc/cpuinfo, ls /dev/null, echo "hello" > /tmp/a.txt — three different operations, all using the same open/read/write system calls. Why? The answer is VFS (Virtual File System Switch) — an abstraction layer that... » read more

K10 — NUMA Systems: Memory Nodes and Local Allocation

dean
K10 — NUMA Systems: Memory Nodes and Local Allocation Key Insight: On multi-socket servers, “local memory” and “remote memory” access latency can differ by up to 3x — NUMA is the source of this difference. The Concept of NUMA NUMA (Non-Uniform Memory Access) means each CPU core has local memory. Local access is fast, remote... » read more