Mastering C for Kernel Development
Cover of Mastering C for Kernel Development by Joseph Anthony C. Hermocilla: a foggy forested mountain range in muted greens and grays.

A free companion textbook

Mastering C for
Kernel Development

Learn C by reading and writing real 64-bit operating system kernel code.

About the book

Mastering C for Kernel Development is a free, open textbook that teaches the C programming language through the lens of 64-bit operating system kernel development. Each concept—types and portability, pointers, structures, inline assembly, interrupts, paging, and dynamic memory—is paired with real code from a small x86-64 teaching kernel, so readers with basic C experience learn to read and write actual kernel code. Written by Joseph Anthony C. Hermocilla for CMSC 125 (Operating Systems) at the University of the Philippines Los Baños, and released under the CC BY 4.0 license.

Table of Contents

  1. Types and Portability
  2. Structures, Packing, and Hardware Interaction
  3. Pointers and Memory
  4. Inline Assembly and Talking to Hardware
  5. Interrupts, Function Pointers, and Event-Driven Programming
  6. Dynamic Memory Management
  7. Paging and Virtual Memory
  8. Building a Heap
  9. Bit Manipulation and Flags
  10. Linking C and Assembly
  11. Building Reusable Kernel Code
  12. The Freestanding C Environment
  13. Reading and Writing Kernel Code
  14. Debugging a Kernel
  15. Thinking Like a Kernel Programmer
  16. Learning by Experiment

Appendices

Resources

Frequently Asked Questions

Is the book free?
Yes. It is free to read and download under the Creative Commons Attribution 4.0 (CC BY 4.0) license, so you may share and adapt it with attribution.
Who is it for?
Students and programmers who already know basic C and want to read and write real kernel code. It was written for CMSC 125 (Operating Systems) at UP Los Baños.
What does it cover?
Types, pointers, structures, inline assembly, interrupts, paging and virtual memory, heap allocation, linking C with assembly, and the freestanding C environment — across 16 chapters and 3 appendices.
What codebase does it use?
A small 64-bit x86-64 teaching kernel. Every concept is tied to real source files you can build and run.
What format is it in?
A PDF of roughly 209 pages, with the source available on GitHub.

How to Cite the Book

APA

Hermocilla, J. A. C. (2026). Mastering C for kernel development. Retrieved from https://jachermocilla.org/publications/books/mckd/ (Licensed under CC BY 4.0)

BibTeX

@book{hermocilla2026masteringc,
  author    = {Hermocilla, Joseph Anthony C.},
  title     = {Mastering C for Kernel Development},
  year      = {2026},
  publisher = {Self-published},
  url       = {https://jachermocilla.org/publications/books/mckd/},
  note      = {Licensed under CC BY 4.0}
}