Operating System Layers

Operating System Layers

Conceptually, the Linux operating system is similar to an onion. It consists of many layers, one on top of the other. At the very core is the interface with the hardware. The operating system must know how to communicate with the hardware or nothing can get done. This is the most privileged aspect of the operating system.

Because it needs to access the hardware directly, this part of the operating system is the most powerful as well as the most dangerous. What accesses the hardware is a set of functions within the operating system itself (the kernel) called device drivers. If it does not behave correctly, a device driver has the potential of wiping out data on your hard disk or “crashing” your system. Because a device driver needs to be sure that it has properly completed its task (such as accurately writing or reading from the hard disk), it cannot quit until it has finished. For this reason, once a driver has started, very little can get it to stop. We’ll talk about what can stop it in the section on the kernel.

Above the device driver level is what is commonly thought of when talking about the operating system, the management functions. This is where the decision is made about what gets run and when, what resources are given to what process, and so on.

In our previous discussion on processes, we talked about having several different processes all in memory at the same time. Each gets a turn to run and may or may not get to use up its time slice. It is at this level that the operating system determines who gets to run next when your time slice runs out, what should be done when an interrupt comes in, and where it keeps track of the events on which a sleeping process may be waiting. It’s even the alarm clock to wake you up when you’re sleeping.

The actual processes that the operating system is managing are at levels above the operating system itself. Generally, the first of these levels is for programs that interact directly with the operating system, such as the various shells. These interpret the commands and pass them along to the operating system for execution. It is from the shell that you usually start application programs such as word processors, databases, or compilers. Because these often rely on other programs that interact directly with the operating system, these are often considered a separate level. This is how the different levels (or layers) might look like graphically:

Image – Operating system layers. (interactive)

If you are running Linux with a graphical interface (e.g. the X Windowing System), you have an additional layer. Your shell might start the graphical interface, which then starts the other programs and applications as we discussed.

Under Linux, there are many sets of programs that serve common functions. This includes things like mail or printing. These groups of related programs are referred to as “System Services”, whereas individual programs such as vi or fdisk are referred to as utilities. Programs that perform a single function such as ls or date are typically referred to as commands.