Operating systems are key to the modern computer. If your computer didn’t have an operating system there wouldn’t be much point to calling it a computer as it would be very hard to use. This month I’ll be giving a rundown of what an operating system (OS) is and just what it does. As with some of the past articles, articles could be written in depth about each of the sections that I am going to cover.
From the perspective of a user an operating system provides an interface to their computer, an interface in many ways. Your operating system provides you with a way to interact with applications, files, and the hardware itself. Each of these can be thought of as an end product in a chain of events. A user activates these events by using an interface which is also governed by the same chain of events. In reality, the user experience of an operating system is only the end result, today we are going to look into everything needed to reach that end result.
Operating systems have always maintained the same general focus to provide hardware management, IO interrupts, and multitasking to name a few. Prior to the 1950s computers were large, very large, and on these computers were physical switches that would be toggled to indicate which instructions were to be executed. Following this came punch card programming in which the user would punch holes in a card to form instructions, these would then be executed with output being printed on a paper tape. In the 1950s mainframes were the computer of choice. These computers introduced many modern operating system concepts including but not limited to multitasking and system resource management. In the 1970s a very important operating system called Unix was created. Over time Unix created a blueprint for what a modern operating system came to be. Unix ran on both mainframes and Intel 8086 based machines.
We could continue and look into how Mac OS has evolved or how Windows has evolved from DOS but a basic history of operating systems is all that is needed at this point. Next we are going to go through all of the major parts of an operating system.
The first and most important component of an operating system is the Kernel. The kernel at its most basic level is an interface between the system hardware and the applications. If an application wants to read a memory address it will make a system call which will be received by the kernel, the kernel will then grab the contents of that address from the physical memory. The kernel is highly protected, if a user tries to access memory that the kernel has reserved they will be denied. This is crucial since the kernel manages all device drivers and modifying device driver memory could result in a fatal system crash. If you get a blue screen of death (BSOD) it’s most likely been caused by a faulty device driver, this being an example of a fatal system crash. There are different types of Kernels, the most popular being monolithic and micro kernels. Monolithic means that all services run with the main kernel process. A microkernel is just that, small. The microkernel simply provides the most basic tasks an operating system would need such as multitasking and memory management. Mac OS X and Linux use monolithic kernels, Windows NT (2000, XP, Vista, 7) use a hybrid type kernel, and microkernels are most often used in supporting virtual machines.
With the kernel set aside managing our device drivers and other hardware it’s only fitting to look at interrupts. Interrupts are exactly that, a way to interrupt the flow of the operating system to respond to events. Interrupts are built into all modern CPUs. An interrupt may be used for signaling a computer that it must stop what it’s doing and handle something more important. This more important task might be accessing the hard drive to save a file or sensing which key you’ve pressed. When an interrupt occurs the current program state is saved for future execution. After the interrupt has been successfully handled control is returned to that program. Combined with the speed of modern CPUs and that operating systems assign priorities to tasks a user rarely notices an interrupt today. When Windows 98 was common we would often experience complete lockups, these lockups were often due to interrupts not being handled properly. Combined with moving to a hybrid kernel structure, faster CPUs, and better prioritizing operating system lockups rarely happen anymore.
Memory management is handled by the kernel. Memory management is crucial so that program A does not inadvertently use memory reserved by program B. If a programmer allocates a block of memory for a list of objects and somehow manages to move out of this allocated range the user will be greeted with a segmentation fault and the program will stop. Memory is allocated in units called pages. A page is a memory unit of a specific size, this size is determined by the operating system. For example, on many Linux operating systems the page size is 4096 bytes or 4kB. Virtual memory is also managed by the kernel. Virtual memory addressing provides the program with a segment of continuous memory. This memory may reside in RAM or on the hard drive. If the system does not have enough memory swapping will occur. Swapping is the process of using a segment of hard drive space as memory, this is slower as disk access times are slower than memory access times.
When a person sits in front of their computer and is watching a YouTube video and playing RuneScape they are multitasking. The operating system has to be able to perform these tasks with the appearance of consistency. In recent years this has become easier with dual and quad core processors but a significant amount of the work is done in the kernel. If a user only has a single core processor the kernel must control which processes are being executed and when. This is determined by process priority (a mouse would have higher priority over a keyboard) and scheduling. This means that control is passed from one process to another as determined by the kernel and the criteria that have been set. If a user has a dual core or quad core processor the kernel has to be aware of the amount of cores in order to become more efficient. As a side note, this is the biggest problem with multi-core CPUs, both the operating system and the applications have to be multi-core aware to see any benefit.
There are many other aspects to an operating system such as disk management or the network stack that I could describe but this article is already running long. I am going to wrap up with an example of program execution. If you opened Firefox to read this article in doing that memory was allocated by the kernel. Memory was then modified when you loaded a web page in Firefox. Interrupts were observed while you typed in the URL to RSBANDBInformer! The browser then put out a call to the networking stack to handle the connection for the browser’s HTTP request. Once the page was loaded its resources were cached to your hard drive for fast access later on. More complex programs such as a game would access your graphics card hardware which is also controlled by the kernel. Please also keep in mind that this is the general flow of control, each of these steps are involved and could have a comprehensive essay written about each one.
Next month I’ll be doing a comparison of modern operating systems and their architectural underpinnings and how that creates the strengths and weaknesses for those operating systems. As always if you have any questions you can send me a private message on the forums.