In Chapter 14 we mostly talked about what an Operating System is and why they are so critical to make a device usable. In other chapters we looked at many physical components and devices that make up a computer. Now you are ready to see the immense power of the intangible. The magic of well built software that helps the hardware come alive.
Recap | What is an OS?
Somewhat ✂️ and 📋 from Chapter 14...
The Operating System (OS) is the software that is designed and built for a device with the intention that a human can perform basic functions on the device without needing to know everything about the underlying hardware.
Managing and operating hardware is not trivial! In fact humans generally find it much more enjoyable to interact with application software. For this reason, a device generally comes with a number of system software in order to hide the complexity of the hardware e.g. disk defragmenter to optimise secondary storage usage, but the OS is the most important one by far!
The Operating System is the most important software because it is the layer that sits between the application software and the computer hardware.
In the definition above we highlighted some key parts because in this topic we will be branching out on those. We already touched on some basic functions in the other chapter so let's start with what we know.
Basic Functions
The list really depends on the device but for the purpose of this topic we are keeping in mind devices like personal computers or laptops and smartphones or tablets. A human that buys any one of these devices would definitely like to...
Run several applications concurrently.
Perform several managerial tasks, for example managing input/output devices or organising a file system, by interacting with a nice Graphical User Interface (GUI).
Swiftly and easily move data across applications and storage devices.
Be able to connect to a wireless router/modem for internet access.
Switching On or Booting Up a Device
The Operating System is permanently stored on the hard disk or solid-state drive (SSD). When you hit that on button on your laptop or phone, the first thing that happens is the loading of the OS into RAM. In order to do this the device comes with firmware. Firmware is machine code (ones and zeroes) hard coded into ROM by the device manufacturer. It cannot be rewritten or deleted. The specific program that loads the OS is called the bootstrap loader.
Managing Resources
The Operating System must manage the resources of the device so that the human won't have to. Resources mostly refer to the hardware like the CPU, memory, secondary storage, input/output devices and so on... People that buy a device run applications that need to make use of these resources. We already mentioned that users expect to be able to run multiple applications at the same time and this is a huge challenge for the OS because for sure there will be more software than hardware!
Therefore a lot of resources must be shareable. When multiple programs are running at the same time, under the direction of the OS, they are probably sharing
Parts of RAM that are read-only.
CPU using techniques like time-sharing.
Read-only files.
There are resources that cannot be shared meaning that the OS can only grant resource access to one application at any point in time. A few examples of non-shareable resources listed hereunder.
A few input/output devices e.g. printer, mouse, keyboard.
Some accelerators like cache memory and GPU.
Writeable files
The Operating System is mainly responsible for managing resources like CPU, memory, I/O and files so that multiple applications can run concurrently on a device.
Managing Files
The OS keeps an index that indicates the location of the files in the RAM. Another data structure, for example the FAT, keeps track of the location of the files on secondary storage. The operating system can save files in empty places and mark as empty places where files have been deleted.
Managing Memory
The OS, like a parker, decides where files should stay inside the RAM. Often, not the whole running program is copied in the RAM. Only the necessary part that is currently required is. If another part of the program is required and the RAM is full, the OS will decide which part of the memory will be freed so that the necessary code or data are placed inside the RAM.
Remember that the CPU works only on data and programs that are in the RAM.
Managing CPU
The CPU is shared between the programs requesting it. One common use of the CPU is time-sharing. This means that the OS will assign the CPU to programs one after the other, for example, the CPU runs program A for one second, then stops and continues program B, then stops and runs program C, then stops and runs program A again, then B again etc. It will appear that the CPU is running A, B and C concurrently.
Managing I/O
The OS also controls the input and output of the computer. Let us consider the keyboard.
The OS is always waiting for the signal ‘press a key’ from the keyboard. When this occurs, the OS is responsible for displaying the character pressed on the screen. Same for the mouse, the OS waits for a particular signal to happen. The signal triggered in this case could be ‘move the mouse’, ’right click’, ’left click’ etc. The operating system responds according to the event. If, for example, the left button is clicked, the OS will call the appropriate program to display a menu on the screen. Likewise, the OS sees that the printer is not overwhelmed with documents to print. So, it keeps a record of the files to be printed in a queue so that when a document is printed (all the pages) another document is printed etc.
Where Does the Human Come In?
I must have mentioned previously that the humans operating devices are normally referred to as users. Also, as we already said it is very important that the OS hides the nitty gritty details of the hardware but ultimately the user must always feel in control! The OS is ultimately working for the benefit of the user.
How can a user communicate with the OS? The layer that a human directly interacts with to make use of any software is referred to as a user interface (UI). The OS is no exception of course and below is a list of the most common UIs for an OS (in order of popularity).
Graphical User Interface
GUI in short, these use windows, icons, and pop-up menus. They have become standard on personal computers. Icons representing real world objects can be moved round the screen and have actions performed on them e.g. drag and drop. Even novice users find these types of systems easy to use. Natural User Interface
NUI in short, have become really popular. The best example of NUI is your smart phone. Humans operate a device and give commands using touch, voice "Hey Google...", and hand gestures.
Menu Driven Interface
This has really blown up in fast food restaurants. This is the one in which you select command choices from various menus displayed on the screen. These are also the standard in small dedicated computers like alarm systems.
Command Line Interface CLI in short, the user types the commands and from the keyboard. Though not very popular for general usage it is still very popular amongst coders and engineers.
Comments