CS 100 (Learn)CS 100 (Web)Module 02


Operating Systems

Different Operating Systems

You are probably familiar with or have heard of the most popular desktop operating systems:

and the two most popular mobile operating systems:

If you are a gamer, you may also use an operating system from Nintendo or Sony.

Many people are very passionate about their choice of operating system. Some are so passionate that their operating system evokes a sense of "tribalism" and they frequently disparage other operating systems. This tribalism is even fostered by some companies to create brand loyalty.

Part of the reason this behaviour is so fascinating (from a sociological perspective) is that different operating systems resonate with different "philosophies" or "core political values". Consider two somewhat extreme positions:

We are not passing any value judgement, but rather attempting to illustrate how the choice of operating system can resonate with different philosophies or value systems.

It might surprise you that there are different "flavours" of Linux and corresponding "sub-tribes" that passionately disagree over the minor differences between those flavours. This (unfortunately) appears to be the human experience.

Operating System Components

An operating system is primarily composed of three things:

Ironically, the kernel is the most important but it's the last two elements (bundled apps and the shell) that most users focus on and cause many operating system debates.

Bundled applications make operating systems more useful, and are an important factor for consumers, but they are really just applications and they do not really change our understanding of what an operating system does.

An operating system needs to interact with the user. The shell provides an interface for the user to interact with the operating system. The shell typically facilitates:

While it can be frustrating switching to a different shell, most modern shells have been designed to be "user-friendly" and intuitive. Operating system shell designers also steal (or "borrow") ideas from each other because good ideas are worthwhile pursuing in any environment.

Operating System Kernel

The kernel is the most important system program and the "heart" of the operating system. Most people have never heard of an operating system kernel, but we might as well learn the proper terminology. The kernel has two main responsibilities:

Both of which involve managing the security of the computer.

First, we will explore how the kernel manages the CPU. Most powerful computers are capable of running multiple applications at the same time. In addition to the applications, there are likely dozens of services running at the same time in the background. However, it is only an illusion.

Most CPUs can only run one program at a time. As mentioned previously, modern CPUs have multiple cores so a quad-core CPU can run four programs at the same time, but this is still far less than the dozens of programs that appear to be running at the same time. The illusion is maintained because the kernel is constantly switching between different programs.

For example, one second of a CPU might look like this sequence of programs running:

    App A (5 ms)
    App B (20 ms)
    Service X (3 ms)
    App A (5 ms)
    App C (15 ms)
    Service Y (2 ms)
    App B (10 ms)

Because everything is happening so fast, it appears to the user as if apps A, B and C are all running at the same time and the illusion is maintained.

The CPU is a resource, and it is the kernel's responsibility to manage that resource. The kernel prioritizes applications and services to decide how much CPU time each will receive. Applications such as video games or movie players typically need more CPU time to ensure that the game or movie runs smoothly. If there are too many applications running, or the kernel is not prioritizing properly, the computer can appear unresponsive or "jerky".

How the kernel actually switches between the applications is a little complicated, but we have seen how something similar happens with peripherals. Previously, we described how an event-based peripheral like a mouse can "wake up" the CPU to respond to the mouse's information. Whenever the CPU is "woken up" it is the kernel's responsibility to decide what to do next. Computers are equipped with a timer to automatically "wake up" the CPU at a fixed time interval (e.g., every millisecond) so the computer can be responsive.

Earlier we described how essential primary memory is for the computer to run smoothly. Just as the kernel allocates CPU time to each process, the kernel must also allocate areas of primary memory to each application. The more primary memory there is, the more applications that can be running at the "same time". If there are too many applications running or the kernel does not allocate enough memory to an application, it will have to over-use secondary storage, which is significantly slower.

Another aspect of memory management is security. The kernel coordinates with the CPU hardware to ensure that an application cannot access the memory allocated to other programs. For example, if one of your applications is your banking software, you want to ensure that none of the other applications can access that information.

The final resources that the kernel manages are the peripherals, which is primarily done through what we have described as application requests. For example, if an application wants to capture an image from the camera, it makes a request to the kernel. The kernel may only allow one application at a time to access a peripheral (e.g., a camera) or allow multiple applications access (e.g., audio/speakers). When a peripheral generates an event (e.g., a mouse click or a key is pressed) the kernel has to decide which application(s) will respond to the event.

In addition to accessing peripherals, application requests also include:

The security surrounding how modern operating systems manage system requests is becoming known as app permissions (especially on mobile devices). For each application, the operating system maintains a list of permissions that the user has granted the application. For example, on a mobile device the user may grant access to the camera, but not their location (GPS) or their contacts. The kernel may also grant an application limited or restricted access, such as only allowing an application access to secondary storage files in a specific folder.