Operating Systems

An Overview of Operating Systems

Operating Systems are a complex topic. In this article, I hope to provide some insight about the terminology, core concepts, and the design of Operating Systems. Including how the kernel, services, and devices drivers operate. This article is intended for intermediate users, and knowing a programming language such as C/C++/Python is recommended.

The Kernel

The Kernel is the heart of the Operating System. It is the first “program” executed when the system has finished booting (Or, it may be responsible for booting itself). The Kernel handles a majority of the functionality that programs rely on, including system calls (for memory management or devices), process management/multitasking, error protection, and device interaction (Disk, USB, or any external I/O device). Essentially, the Kernel is the bridge between services/user programs and the hardware (the CPU, Memory, or other devices).

Because the Kernel provides such important technology, it is often loaded into a protected part of memory, out of reach of normal, user space programs. Other protections, such as encryption or address randomization, may be used to protect the system from damage, intentional or accidental.

Device Drivers

A Kernel can only do so much. Individual devices, such as Hard Disks or Keyboards may have different functionalities or requirements to operate. Because of this, an abstraction is needed to prevent operating systems from being bloated with hardware-specific functionality.

This is where device drivers come in. They are external “programs” which act as an abstraction, or interface, to specific hardware such as keyboards, network adapters or hard drives. Often times, device drivers can be installed or are preloaded with consumer operating systems.

Device Drivers can have the same access level as the Kernel, and often times this means they are subject to the same scrutiny and protection as them. Installing a device driver from a suspicious source is dangerous, as you are giving a program “the lowest root” access to your system.

Services

Services are similar to device drivers, but may run in a less privileged level than device drivers. These may include certain utilities, such as Wireshark or VirtualBox, that require a higher privilege level than typical programs but not root access to kernel-level systems.

Services are often diverse, Windows 10 may have hundreds of services installed/running at the same time. Services offer functionality to specific or a wide range of programs, such as inter-process communication, networking or error handling. You can see running services by typing “Services” in the search bar on Windows 8 and above.

Operating System Principles: Services, Resources, and Interfaces CS 111 Operating  Systems Peter Reiher. - ppt download
An illustration of the privilege layers for an Operating System. The higher the object, the less privilege over the system the program has. As you can see, Services are sandwiched between User Programs and the Kernel/Device Drivers.

The Bootloader

Often times, you will encounter a Bootloader when you encounter a critical error in Linux, or when developing a Operating System for yourself. A Bootloader is a program run when a computer is turned on, and is responsible for setting up the environment for an Operating System to run. This may include setting up memory pages, switching the cpu to a different mode, and initializing interrupts.

Many developers may create their own Bootloader for their operating system, however, there are many bootloaders designed for a wide range of operating systems. An example of this is GRUB, which was designed for Linux.

Writing a bootloader is a complex task. Without any external libraries and often in Assembly, a programmer requires intimate knowledge of the CPU architecture(s) involved. An understanding of the internal components of a computer would help greatly as well.

Interrupts/Traps

Our final term is Interrupts and Traps. These are a complex function of operating systems, and are critical for switching between user and kernel programs, as well as handling errors that would otherwise damage the system.

To put it simply, an interrupt is a defined condition that, when met, will pause the flow of execution (saving the state of the current running process/program, through multiple means) and run a interrupt handler. An interrupt handler is an operating system program/function which defines the actions to take when an interrupt happens. For example, an interrupt is called when a key is pressed on the keyboard. An interrupt handler handles this event, which may include gathering information such as the key pressed or the language of the keyboard. Once this is done, the kernel may return execution back to the paused program.

Finally, a Trap is simply an Interrupt that occurs when an exceptional event, such as an error, occurs. An example may be a Trap that is called to handle a division by zero (oftentimes called a Zero Divisor Interrupt). This may include sending an error message to the kernel, which is then handled dependent on the OS, or returning a garbage value. More on traps here.

Conclusion

With these in mind, I hope you gained some insight about the usage of these components in a Operating System. Each of these systems have their own topic which can be explored deeper. A great website for more insight is the OSDev Wiki. Consider browsing there for more information.

With that in mind, I hope you enjoyed reading. Thank you for your time.

~Zeek Halkyr

2 thoughts on “An Overview of Operating Systems

Leave a Reply