Stephen Marz
About Me | Teaching | Courses | Research

Personalized Courses

Canvas LMS (Requires NetID login)

Writing an OS

Writing an Operating System (COSC493-002 [Fall 2018])

Prerequisites: B or higher in COSC360 (System's Programming) or COSC361 (Operating Systems) and Consent of Instructor

This course entails writing an operating system from the start and becoming intimately familiar with the underlying architecture of the x86-64 CPU. The goals of this course are as follows:

Assembly / Compiling Tools

  1. Learn how to use system instructions in x86-64 assembly
  2. Learn how to interface assembly and higher-level languages, such as C/C++
  3. Learn how to create a linker script to place programs at a proper memory location
  4. Learn how to create a Makefile to ease the building process
  5. Learn how to use GIT as a source code manager (SCM)

Boot Sequence

  1. Learn about how a BIOS transfers control to a bootloader in 16-bit, real mode
  2. Learn how to load a second stage bootloader from real mode
  3. Learn how to transition from 16-bit, real mode into 32-bit, protected mode
  4. Learn how to read a kernel from a disk drive using ATA commands
  5. Learn how to transition into 64-bit, long mode
  6. Learn how to transfer control to a high-level language, such as C or C++

Memory Management

  1. Learn how to effectively manage 1GB, 2MB, and 4KB page sizes
  2. Learn how to statically and dynamically allocate memory in a low-level, freestanding environment
  3. Learn how to partition memory between kernel and user pages
  4. Learn how to implement a copy-on-write (COW)

I/O Management

  1. Learn the difference between the PIO and MMIO techniques for reading/writing to I/O devices
  2. Learn how to read from and write to the PCI (Peripheral Component Interconnect)
  3. Learn how to enumerate a PCI bus

Interrupt Management

  1. Learn how to accept and handle vectored interrupts, including faults
  2. Learn how to handle MSI and MSI-X (Message Signaled Interrupts)
  3. Learn how the APIC (Advanced Programmable Interrupt Controller) functions in the CPU
  4. Learn how to context switch between privilege levels (user mode vs kernel mode)

Process Management

  1. Learn how to schedule tasks in the operating system
  2. Learn how to create and manage preemptible tasks
  3. Learn how to switch between user mode and kernel mode

Symmetric Multiprocessing

  1. Learn how to awaken halted CPU cores by using the APIC
  2. Learn how to schedule tasks and apportion their jobs among multiple CPU cores
  3. Learn how to effectively avoid race conditions and other critical common section problems

Grading / Evaluation

This course has been designed to accomplish these goals with influence from the instructor and from guided self-study.

All information regarding grading and evaluation will be on the course's Canvas site.


At the final week of this course, the student should have a working operating system with minimal features.


Writing an operating system is a very involved undertaking, and it is unrealistic to believe that a fully-featured operating system can be written in a single semester. Do not get your expectations too high, but the point of this course is to have hands-on fun while learning the low-level intricacies of the Intel/AMD x86-64 computer architecture.

About Me | Teaching | Courses | Research