What is an Operating System?

What is an Operating System?

You may be familiar with operating systems such as Windows, MacOS, Linux and Android, but what does an operating system do and why is it necessary?

A computer does not actually require an operating system (O/S) at all. In the early days of computers it was quite common to run a machine without one. Software could be loaded by switching the machine on, inserting a disk and the required software would boot directly from the storage medium. Well into the 1990s it was still commonplace to boot individual software titles in this way, particularly on lower end home machines and games consoles.

The Amstrad PCW (below) was a low cost personal computer originally released in 1985 that booted the majority of software by inserting a disk containing the relevant title into the drive without first starting an O/S. It could also run an operating system called CP/M, although this was optional.

An Amstrad PCW 8512 with printer.

Even today it is still technically possible to load software onto a personal computer with no O/S, although it would be difficult to find any modern software title that is capable of running in this mode. Gradually over time PCs became less usable without operating systems and for running almost all software, it became a requirement. What the operating system provides is a certain set of conveniences and those conveniences have become so essential in modern times that it is now almost inconceivable to run a machine of any sophistication without an O/S.

The first thing an operating system does is provides layers of abstraction between programs and the hardware. There are a myriad of hardware devices on the market and on purchasing a device the user expects it to work with all of their software. While this might now seem like an obvious expectation barely worth mentioning, this was not always the case. If you bought a printer it would be necessary to individually check in advance if it worked with each and every item of software that you owned. Each printer works differently and software would need to support each printer model separately. This is very inconvenient and not really a sustainable approach. There are hundreds of different printers on the market with new ones appearing all the time and having to write specific code for each one is a near impossible expectation. It was often the case you would find one piece of software worked with the printer you had but another software title did not.

An operating system delivers support for all of the different kinds of printer available and presents a unified abstraction layer. This makes all the printers appear to be identical which makes writing a program to print something out considerably easier. The programmer now writes code as if developing for only one kind of printer, then the operating system translates this into the requirements of whatever obscure printer the user may have chosen to plug in.

If you think about all of the kinds of devices on the market that you may wish to connect to a computer, it would be near impossible to support them all in every program. There are cameras, USB sticks, monitors, microphones, video cards, scanners, keyboards, mice and a million other things from thousands of brands, each one slightly different. A computer doesn’t intrinsically understand what to do with any of these devices, software needs to be written to control each and every one. An operating system supplies the programmer with an easy and unified way to access all of these devices without needing to consider each device individually.

Another problem is that there may be more than one way to use any specific device. If you imagine a storage device, one program may decide to write files starting at the beginning of the disk. Another program might decide to start writing files from the end. Perhaps one program might allow file names containing numbers and letters but another may allow only letters. One program might decide to support folders but another program does not. One program may allow files to have an icon but another doesn’t. There are all kinds of ways in which a storage device might be used. The operating system defines a series of strict conventions that all of the programs must stick to. This ensures that one program can always reliably read the files written by another. Without these conventions being defined, this would not be the case.

The next thing an operating system does is provides libraries of helpful or boilerplate code. That is, code that many programs have in common and are likely to want to use. Drawing a window on the screen with the capability to drag it around with a mouse isn’t easy to code. However it used to be the case that each individual program would be required to do this separately. These days the operating system supplies all of that code for us and so few people ever need to write that any more. Communicating with the internet is quite complex and is something a lot of software needs to do. Again this code is supplied by the operating system and so each program doesn’t need to include it on an individual basis. Drawing 3D graphics requires a great deal of mathematical skill, but modern operating systems now supply features to do this.

An operating system manages the simultaneous operation of many programs at the same time. Originally a computer would only run one program at once. Imagine the tremendous inconvenience of typing in a wordprocessor and deciding that you need to refer to a spreadsheet. In order to do this you have to save your work, reset the computer, boot up the spreadsheet, refer to it, reset the machine, boot up the wordprocessor and load your work back in again to continue where you left off. A very tedious process indeed. An operating system provides facilities to allow more than one program to be active simultaneously.

Not only does an operating system provide facilities for multiple programs to be loaded at the same time, but enables them to actually run at the same time. This is not something that a computer intrinsically knows how to do. Some older less sophisticated operating systems didn’t allow this. You could have two programs loaded into memory simultaneously and you could instantly flip between them, but they would not actually run concurrently. Each program would only run when the user was viewing it. You couldn’t play music in the background whilst typing a report. You could view the report or listen to the music but not both at the same time. The operating system feature that allows concurrent running of multiple programs is called multitasking.

Where multiple programs are loaded at once, the operating system determines where those programs will end up in memory. Each program requests the amount of memory it needs and the operating system allocates some space for it to use. The memory space is marked and protected such that no other program can request the same space as if two programs write into the same memory locations for different purposes they will both likely crash.

Lastly an operating system is often bundled with a collection of basic software that is helpful for the user. It doesn’t necessarily have to include such software but often does. Bundled software might include back-up utilities, data compression (like zip), anti-virus, a wordprocessor, a video player and so on. The exact collection of software an operating system is bundled with is one of the main differentiators of operating system distributions (different editions of the same O/S).

Many people associate the desktop environment with the operating system, but this is just another bundled program. The desktop environment makes it easier to manage files and start other programs (for example by displaying the task bar). The desktop environment is however just a just a standard program exactly like any other and there is nothing special about it. It can be stopped and the operating system remains running and it can be swapped out with an entirely different desktop environment which looks completely different. The desktop environment is usually set to start automatically when the computer boots to help make the computer more friendly and usable, but doesn’t have to be. Computers that are not expected to be directly interacted with by users, such as servers, often do not start a desktop environment automatically on boot as it is not required.

Image Credit: Amstrad PCW by Marcin Wichary