How To Program Your Very Own Operating Systems (OS)
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
There aren't really any development fields more challenging than operating system (OS) development. It is the "great pinnacle of programming."
Few programmers ever attempt to build an OS and many of those who do make the attempt never produce a functioning system.
However, if you do make it all the way to the finish line and produce a functional operating system, you will have joined an elite group of top-flight programmers.
What is an Operating System?
The earliest computers did not have operating systems.
Every program that ran on these early systems had to include all of the code necessary to run the computer, communicate with connected hardware, and perform the computation the program was actually intended to perform. This situation meant that even simple programs were complex.
As computer systems diversified and became more complex and powerful, it became increasingly impractical to write programs that functioned as both an operating system and a useful application.
In response, individual mainframe computer owners began to develop system software that made it easier to write and run programs and operating systems were born.
An operating system (OS) is software that manages computer hardware and system resources and provides the tools that applications need to operate. The birth of operating systems meant that programs no longer had to be written to control the entire scope of computer operation.
Instead, computer applications could be written to be run by the operating system while the operating system worried about computer resources and connected peripheral equipment such as printers and punched paper card readers.
A Brief History of Operating Systems
The first operating system was created by General Motors in 1956 to run a single IBM mainframe computer. Other IBM mainframe owners followed suit and created their own operating systems.
As you can imagine, the earliest operating systems varied wildly from one computer to the next, and while they did make it easier to write programs, they did not allow programs to be used on more than one mainframe without a complete rewrite.
In the 1960s, IBM was the first computer manufacturer to take on the task of operating system development and began distributing operating systems with their computers.
However, IBM wasn't the only vendor creating operating systems during this time. Control Data Corporation, Computer Sciences Corporation, Burroughs Corporation, GE, Digital Equipment Corporation, and Xerox all released mainframe operating systems in the 1960s as well.
In the late 1960s, the first version of the Unix operating system was developed. Written in C, and freely available during it's earliest years, Unix was easily ported to new systems and rapidly achieved broad acceptance.
Many modern operating systems, including Apple OS X and all Linux flavors, trace their roots back to Unix.
Microsoft Windows was developed in response to a request from IBM for an operating system to run its range of personal computers.
The first OS built by Microsoft wasn't called Windows, it was called MS-DOS and was built in 1981 by purchasing the 86-DOS operating system from Seattle Computer Products and modifying it to meet IBM's requirements.
The name Windows was first used in 1985 when a graphical user interface was created and paired with MS-DOS.
Apple OS X, Microsoft Windows, and the various forms of Linux (including Android) now command the vast majority of the modern operating system market.
The Parts of an Operating System
Operating systems are built out of two main parts:
- The kernel;
- System programs.
The kernel is the heart of the operating system. It is the first program loaded when the computer starts up, it manages computer resources, and it handles requests from system programs and applications.
System programs run on top of the kernel. They aren't used to perform useful work, instead, they are the programs necessary to connect the kernel to user applications and peripheral devices. Device drivers, file systems, networking programs, and system utilities like disk defragmeters are all examples of system programs.
Application programs aren't part of the operating system and are the programs used to perform useful work. Word processing applications, browsers, and media player are common types of application programs. Application programs are managed and enabled by the kernel, and use system programs to access computer periphery devices and hardware.
What You Need to Know
The list of things you need to know before you attempt to undertake operating system development is very long. The three most important things you need to master prior to jumping into OS development are:
- Basic computer science knowledge;
- Computer programming theory and best-practices;
- Low-level and a high-level programming languages.
Learn Computer Science
OS development isn't like web development. It isn't something you can jump into and learn as you go. You need to develop a solid foundation in computer science before moving on to other topics.
Here are some resources to get you started:
Coursera: Computer Science 101 is the course you should take first if you are brand new to the field of computer programming and computer science.
If you have a little knowledge and experience under your belt, skip this course in favor of the Udacity of edX options. However, if you are brand new to the field, this course takes a no-prior-experience approach to introducing computer science and programming topics.
Udacity: Intro to Computer Science takes a web-development approach to teaching computer science. While not directly applicable to the prospect of building an operating system, this is a solid course that delivers useful information and provides a good overview of the basics of computer programming.
edX: Introduction to Computer Science is the most complete and in-depth computer science course in this list. This free, self-paced course was designed by Harvard University and mirrors the content presented in the course by the same name offered on the campus of Harvard University.
Learn Computer Programming
With a solid grasp of computer science under your belt and some limited experience with programming languages, the next step is to learn how to tackle a large-scale programming project.
Udacity: Software Development Process is an excellent course everyone should take if they've never undertaken a large-scale, challenging programming project before. In this course you'll learn workflow and management tools and techniques such as Git and how to set up an integrated development environment.
Learn Programming Languages
In order to develop an operating system, you will need to master at least two programming languages:
- Low-level assembly language;
- A high-level programming language.
Assembly languages are used to communicate directly with a CPU. Each type of CPU speaks a machine language and there is just one corresponding assembly language for each type of CPU. The most common computer architecture is x86, it was originally developed by Intel and is now used by a wide range of computer chip manufacturers including AMD, VIA, and many others. In this guide we will point you in the direction of learning x86 assembly language.
High-level programming languages work with multiple computer architectures. C is the programming language most commonly used and recommended for writing operating systems. For this reason, we are going to recommend learning and using C for OS development. However, other languages such as C++ and Python can also be used.
x86 Assembly Language
The x86 Assembly Guide is a great place to start learning assembly language. This short document provides a brief overview of x86 assembly language and will set the stage for the more advanced resources you'll be moving on to next.
Programming from the Ground Up by Jonathan Bartlett is one of the defining books of the assembly language landscape. This book uses assembly language as the basis for learning computer science and programming. This resource is also available from the Internet Archive.
The Art of Assembly Language by Randy Hyde is another iconic text in the world of assembly language education. Originally written specifically for Hyde's programming courses at Cal Poly and UC Riverside, the text was released as an HTML ebook in the mid-1990s and is recognized as a defining work within the field. The text is also hosted as a series of PDF files by the Yale FLINT Group.
If you want to use a traditional textbook to learn about x86 assembly language two of the most commonly used and highly recommended texts are:
- Assembly Language Step-by-Step: Programming with Linux by Jeff Duntemann;
- Modern X86 Assembly Language Programming by Daniel Kusswurm.
There are many high-level programming languages you could learn and many different resources you could use to learn them. Our recommendation, and the recommendation most commonly echoed by the OS development community, is to learn C, and we've found several excellent resources that will turn you into a competent C programmer.
Get a quick overview of the C programming language by completing this C Tutorial. This resource won't turn you into an expert, but it will give you a good basic understanding of the language and prepare you to tackle more challenging topics and resources.
Learn C the Hard Way is a free HTML ebook that includes many practice exercises. This text walks you all the way through the C programming language, and if you put in the work, take your time, and complete all of the exercises, you'll be well on your way to being a competent C programmer by the time you complete this tutorial.
If a traditional textbook is something you're more likely to work your way through, these two texts are some of the most popular for mastering the C programming language.
- The C Programming Language by Kernighan and Ritchie;
- C Programming Absolute Beginner's Guide by Perry and Miller.
OS Development Tutorials
Once you have a strong grasp of the fundamental concepts of computer science and programming, and have mastered assembly language and C, the next step is to complete one or two OS development tutorials that walk through the entire process of developing a simple OS from scratch. We found three excellent resources that do just that.
Linux From Scratch will walk you through the process of building a complete Linux operating system. Completely this tutorial won't produce a full-fledged operating system, but it will give you a solid code base on which to build out a complete operating system. Tackle advanced tutorials such as Beyond Linux from Scratch, Automated Linux from Scratch, Cross Linux from Scratch, or Hardened Linux from Scratch to build your basic OS into a useful piece of software.
The little book about OS development by Erik Helin and Adam Renberg was developed as part of an advanced computer science course the authors completed while students as the Royal Institute of Technology in Stockholm. This course walks through the complete process of developing an x86 operating system by beginning with setting up a programming environment, culminating in programming for multitasking, and hitting topics such as managing system memory and developing file systems along the way.
Operating System Development Series from Broken Thorn Entertainment is a series of 25 tutorials that walk you through the process of creating an OS from the ground up. Beginners beware: this series assumes you already know your way around an IDE and are a competent C and assembly language programmer.
There are many texts you could use to learn about the discipline of OS development. Three of the most commonly recommended are:
- Modern Operating Systems by Tanenbaum and Bos;
- The Design of the UNIX Operating System by Maurice Bach;
- Operating System Concepts by Silberschatz, Galvin, and Gagne.
OS Development Communities
As you embark on the journey of becoming an OS developer, there are a few places where you can find other OS developers to learn from and commiserate with:
- OSDev.org is a wiki with a great deal of information about OS development as well as a forum where you can meet and get feedback from other like-minded programmers.
- OS Development Channel on reddit is a great community where you can learn about OS development and enjoy a moment of levity when the task of OS development becomes a bit to arduous.
- Computer Science, Programmers, and StackOverflow from StackExchange are places you can pose technical questions to other programmers when you come up against a problem you can't seem to figure out on your own.
Learning OS development is one of the most challenging programming tasks you can undertake. However, succeeding in your effort to build a working OS will mark you as a competent programmer and one who deeply understands how processors, hardware, and computer programs work together to create what the rest of the world takes for granted as a functioning computer.
Also see our other guides on programming languages.