Chapter 16 — Entering User Mode and Returning Through Syscalls

Chapter 16 — Entering User Mode and Returning Through Syscalls
This entry is part 16 of 35 in the series Writing A Linux Style Operating System From Scratch

We now have an interactive, preemptive kernel with memory management, blocking, synchronization, keyboard input, terminal editing, and a monitor. So far, however, everything runs in ring 0. That means every thread has full kernel privilege. There is no separation between kernel code and user code yet. This chapter adds the first user-mode milestone: Intel’s IA-32

Chapter 15 — Command Tables, Argument Parsing, and Shift-Aware Keyboard Input

Chapter 15 — Command Tables, Argument Parsing, and Shift-Aware Keyboard Input
This entry is part 15 of 35 in the series Writing A Linux Style Operating System From Scratch

In Chapter 14, we added the first interactive kernel monitor: That worked, but the monitor command parser was still a chain of if statements: That is fine for five commands, but it does not scale. This chapter cleans that up by adding: The keyboard improvement matters because our monitor is interactive now. A monitor where

Chapter 14 — Terminal Line Discipline and a Kernel Monitor

Chapter 14 — Terminal Line Discipline and a Kernel Monitor
This entry is part 14 of 35 in the series Writing A Linux Style Operating System From Scratch

At this point our kernel has enough machinery to become interactive: Now we will build two new layers: The terminal line discipline turns raw keyboard characters into editable input lines. It handles: The kernel monitor is a small command loop: This is not user space yet. It is still a kernel thread. But it gives

Chapter 13 — Mutexes, Semaphores, and a Console Lock

Chapter 13 — Mutexes, Semaphores, and a Console Lock
This entry is part 13 of 35 in the series Writing A Linux Style Operating System From Scratch

In Chapter 12, we added wait queues and blocking keyboard input: Now we need synchronization primitives that ordinary kernel code can use. This chapter adds: A mutex provides mutual exclusion: only one thread may hold the protected resource at a time. OSDev describes a mutex as a mutual-exclusion mechanism, similar to a binary semaphore, used

Chapter 12 – Wait Queues and Blocking Keyboard Input

Chapter 12 – Wait Queues and Blocking Keyboard Input
This entry is part 12 of 35 in the series Writing A Linux Style Operating System From Scratch

In Chapter 11, we added the first blocking primitive: That gave the scheduler a way to remove a thread from the ready queue until a future timer tick. Now we need a more general primitive: This is the foundation for real kernel I/O. A keyboard reader should not spin like this: It should block: This

Chapter 11 — Blocking Primitives, Sleep Queues, and Scheduler Hygiene

Chapter 11 — Blocking Primitives, Sleep Queues, and Scheduler Hygiene
This entry is part 11 of 35 in the series Writing A Linux Style Operating System From Scratch

In Chapter 10, we added timer-driven preemption: Now we need the next scheduler capability: blocking. A runnable thread competes for CPU time. A blocked or sleeping thread does not. OSDev describes a blocking process as one that waits for an event, such as a semaphore or message, and is removed from the active scheduling queue

Chapter 6 — Building the First Kernel Heap

Chapter 6 — Building the First Kernel Heap
This entry is part 6 of 35 in the series Writing A Linux Style Operating System From Scratch

In Chapter 5, we enabled paging with a simple identity map: That gave us a working paged kernel, but not yet a comfortable way to allocate variable-sized objects. The physical memory manager gives us whole pages: But kernel code usually needs smaller objects: So this chapter builds the first kernel heap. We will keep it

Writing a Linux-style Operating System From Scratch

Writing a Linux-style Operating System From Scratch
This entry is part 1 of 35 in the series Writing A Linux Style Operating System From Scratch

Today, we are beginning a new article series: “Writing a Linux-Style Operating System From Scratch.” In this series, we will walk step by step through the process of creating our own operating system from the ground up. Many operating system tutorials stop shortly after the system boots and prints a simple message on the screen.

Building the i686-elf-gcc Cross-Compiler

Together, these tools allow us to assemble, compile, link, inspect, and transform kernel binaries without using the host operating system’s normal compiler target.

Developing an Open Hardware Device Programmer

This entry is part 1 of 1 in the series Open Universal Device Programmer

Introduction As an electronics enthusiast with over 50 years of experience, I’ve had the privilege of witnessing the dramatic evolution of computing systems. From the early days of 4 and 8-bit machines with minimal RAM to today’s powerful 64-bit computers with terabytes of storage, the progress has been nothing short of extraordinary. The same transformative