All publications
Systems & Internals

Implementing Kernel Threads in xv6

Go beyond processes — a practical guide to adding real kernel threads to a teaching OS.

May 1, 2025 · 22 min read · Preview
Implementing Kernel Threads in xv6

Summary

xv6 gives you processes, but not threads. This article goes into the kernel and adds them: shared address spaces, new system calls, and a scheduler that understands threads. It blends the theory of concurrency with the very concrete work of editing an operating system and watching it run.

Processes are isolated; threads share. This guide takes the xv6 teaching kernel and gives it true kernel threads — shared memory, new system calls, and a scheduler that knows the difference — bridging OS theory and hands-on kernel hacking.

Key ideas

  • 01 A thread is a process that shares its address space with siblings.
  • 02 New syscalls (clone/join) are needed to create and reap threads.
  • 03 The scheduler and trap frames must be adapted to schedule threads, not just processes.
  • 04 Synchronization becomes essential the moment memory is shared.