Between the code and the circuits

The role of operating systems

Jack Holland
Understanding computer science
5 min readApr 15, 2014

--

This is an ongoing series. Please check out the collection for the rest of the articles.

An IBM punched card computer from 1936

As the last posts illustrated, computer processors work at a very primitive level; it is exceptionally difficult to program anything complex using assembly language. While modern computers are more user-friendly than the one above, programming at the level of hardware is still tricky and laborious. Luckily, there are many layers of abstractions between the processor and most programming languages.

What do I mean by layers of abstraction? Take a look at this diagram representing how computers are designed:

This post is about the blue layer and how it relates to the others

While it’s fairly obvious that the user doesn’t interact directly with the hardware, it may come as a surprise that applications don’t either. But the “Operating System” layer that’s sandwiched between the “Application” and “Hardware” layers is quite important. The operating system abstracts away the details of the hardware to make it easier for applications to use it.

In a nutshell, operating systems manage the resources that the hardware provides so that applications don’t have to. But this isn’t simply a matter of convenience; without an operating system to organize what each program has access to, modern computing would fall apart.

To understand why, imagine this scenario: you want to browse the internet and listen to music at the same time. The first problem is that processors can only run one program at a time. How should the computer decide which program gets to run when? Moreover, how should the computer divvy out memory? It’s very possible that the browser tries to write to a part of main memory that the music player is using. Could you imagine if a song got interrupted because you loaded a new web page?

It only gets worse; what if you’re watching a YouTube video and listening to music at the same time? The browser and the music player would try to communicate with the sound card at the same time and the sounds may get garbled. Or, perhaps both programs try to write to the same part of the hard drive. Basically, programs need some kind of manager to handle all of these resource conflicts. They need an operating system; a layer between the programs and hardware that handles the messy details.

But which one to choose? Well, it depends on what kind of computer you’re using. There are operating systems designed for desktop personal computers, laptops, tablets, smart phones, cars, and more. You’ve probably heard of Windows:

As well as Mac:

But have you heard of Linux?

Or GNU?

How about Plan 9?

There are a staggering number of operating systems. To further complicate it, each of the names I listed about aren’t even operating systems; they’re brands of operating systems. The Windows brand includes many versions, like Windows 8, Windows 7, Windows Vista, etc. all the way back to the original 1985 Windows 1.0. Mac has a similarly rich lineage and Linux is even more elaborate; there are over 600 distributions of Linux and most distributions have at least several versions. As you might have guessed, we don’t have time to talk about all of them right now.

What I do want to talk about is which operating system we’re going to use in the near future. While I’ll certainly discuss a variety of operating systems down the road, I’m going to use one as the standard so that you, dear reader, can follow along with what I do. This way, when I provide samples of code and applications, you can load up our favorite operating system and try them out yourself. With that in mind, I’ve chosen a free operating system so that anyone who wants to can download it for themselves.

While I’m aware that this post has been scant on details, I promise we’ll delve deeply into what operating systems are and how they work. The operating system I’ve chosen to use is particularly conducive to this goal because it’s open source — all of its code is publicly available, allowing us to dissect and analyze it as we wish. Without further ado, I present to you an elegant and versatile operating system, Fedora Linux:

Fedora can be downloaded here. There are many excellent guides to installing Fedora and there are a few different ways to do it, depending on what kind of setup you want, so I won’t go into detail here. I would recommend creating a live USB version and playing around with it until you’re comfortable. Don’t worry — I’ll explain how to use any programs we need.

Next post, I’ll introduce you to Linux in more detail and then we’ll learn how to use a terminal, an essential program every computer scientist should understand.

--

--