PreprintPDF Available
Preprints and early-stage research may not have been peer reviewed yet.

Abstract and Figures

Operating Systems are a major part of our lives. Mobile phones, computers and the cloud — which serves as a backbone of the entire internet — utilize them every single day. However Operating Systems are not limited to these complex machines, for example MiniOS which is developed for Arduino. This paper aims to provide a better understanding of how Operating Systems are developed in a very simplistic manner. Furthermore how various components work together to make a computer do things that we expect from it. Developing a fully fledged Operating Systems from scratch is a lot of work and a huge commitment. We will be diving into the details of components such as Bootloaders, Kernels and Drivers which play a key role to make use of the hardware. These “low level programs”, bunched together, working in harmony is what enables us to use our computers and other devices every day.
Content may be subject to copyright.
Piecing together a basic Operating
System
Sakshat Shinde
MIT Academy Of Engineering
April 28, 2020
Abstract
Operating Systems are a major part of our lives. Mobile phones, computers and the cloud — which serves
as a backbone of the entire internet — utilize them every single day. However Operating Systems are not
limited to these complex machines, for example MiniOS which is developed for Arduino. This paper aims
to provide a better understanding of how Operating Systems are developed in a very simplistic manner.
Furthermore how various components work together to make a computer do things that we expect from it.
Developing a fully fledged Operating Systems from scratch is a lot of work and a huge commitment. We
will be diving into the details of components such as Bootloaders, Kernels and Drivers which play a key
role to make use of the hardware. These “low level programs”, bunched together, working in harmony is
what enables us to use our computers and other devices every day.
1. Introduction
An operating system is usually described as a piece of software which enables users to interact with a
hunk of metal. Traditionally one would say it is essentially a program which runs other programs. So that
makes it “the first program”. In other words, everything you do on your computer is totally dependent on
the Operating System, directly or indirectly. A few key components of an Operating System are : the
Kernel, the Bootloader and the Drivers. These three components and many others work together to create
an abstracted layer for the user by which they can interact with the machine easily. Essentially these
programs are the ones who interact with the bare metal. Example when you press a key on your keyboard,
the computer knows which key was pressed and does the job accordingly. Your monitor displays certain
stuff depending on the given input so on and so forth. It also interacts with your RAM, CPU and other
components in different ways. Figure 1 depicts the general flow of interaction.
1
Figure 1: A basic working of an Operating System
2. Bootloader
A bootloader is the program which loads an Operating System into the memory when you turn on your
computer. The bootloader also initializes system hardware. After a successful boot, the control is
transferred to the operating system. Let’s dive into an example.
Here we would be working with an Intel based 32 Bit system. IA - 32
IA - 32 based systems have a BIOS (Basic Input Output System). This particular system is capable of
accessing some basic devices as disks, keyboards and a display. This system contains bootloader code.
Specifically it’s a “stage 1 bootloader” which means it can only be “512 bytes wide” and a lot of this size
may be dedicated to bios structures and FAT headers, which leaves even less space to work with, after
this “stage 2 bootloader” is loaded and then the kernel is loaded. The stage 1 bootloader only exists to
load the stage 2 bootloader.
The processor starts up in real mode, then it switches to protected mode to access 32 bit addressing and
do fancy stuff like virtual memory. One might say how does the BIOS know where does the boot sector
2
actually end on the disk. For that there is a specific number, usually referred to as “magic number”,
0xaa55. This particular number is placed at the end of the boot sector, so the BIOS looks for this number
and confirms that this is a “boot sector”.
A small example of a boot sector written in assembly.
loop:
jmp loop
Times 510 - ($ - $$) db 0
dw 0xaa55 ; Our magic number
We can’t expect to fit our entire operating system in such a small space. So we use “chain loading”. This
is a multi-stage bootloader, a bootloader loading a bigger bootloader. This clarifies why stage 1 and stage
2 bootloaders exist. To make it a bit clearer, you can visualize it as a relay race, the bootloader 1 is
passing the baton to the bootloader 2. But here the baton is bootloader 2 itself.
The basic BIOS startup process is as follows:
1. Power on self test (POST)
2. Detect V-Bios ( Video BIOS is the BIOS of a graphics card ) and initialize the video hardware
3. Detect any other device BIOSes and initialize that hardware
4. Display a startup splash screen
5. Memory Checks / Memory Test ( Finding out how much memory is seeded in the motherboard )
6. Set various memory and drive parameters
7. Assign resources and identify the boot device
3. Kernel
It is the core component of an operating system. It is always loaded in the memory. An operating system
itself is divided into two parts: the kernel space and the user space. The difference between the user space
and kernel space is as follows.
A. User Space : It is a set of locations where normal user processes run, i.e. everything other than
the kernel code
B. Kernel Space : It is the location where the code of the kernel is stored, and executes.
User processes can access a small part of the kernel via an interface exposed by the kernel called “system
calls”. This way a process can talk to a kernel if needed.
3
Examples for system calls :
1. Reading and writing from files demand system calls
2. Creation and deletions of files require system calls
3. System calls create new processes and also manage them
4. Sending and receiving network packets utilize system calls
5. Access to hardware devices need a system calls
There are multiple types of kernels:
1. Monolithic Kernels
2. MicroKernels
3. ExoKernels
4. NanoKernel
Monolithic kernels run basic system serres like memory management, I/O communications, in the kernel
space. Whereas MicroKernels were designed to reduce the kernel to basic process communication and I/O
control. And the other system services to be handled in user space instead. The MicroKernel model was
designed to overcome the limitations of extensibility and maintainability of Monolithic Kernels.
Linux is an Open Source Monolithic kernel. Windows NT is a MicroKernel.
ExoKernels are an experimental approach to operating system design.
An exokernel eliminates the preconception that an operating system provides the necessary abstractions
for the applications to be built upon. Instead, it concentrates solely on securely multiplexing the system
hardware. The basic idea of this kernel is to let it decide the allocation of basic physical resources of the
machine, eg. disk blocks, memory pages and processor time. On the other hand let the applications decide
what to do with these allocated resources and how to utilize them properly and efficiently. The application
itself then can link to a support library that implements the necessary abstractions it needs. Examples of
exokernels are, MIT exokernel, Nemesis exokernel, a commercial exokernel called BareMetal OS,
ExAmour The GNU exokernel.
NanoKernel as the name suggests, the kernel code is very tiny, kernel code being the one executing in the
privileged mode. It offers hardware abstraction, but without system services. There is one case where the
term “nanokernel” actually refers to a kernel which supports nanosecond clock resolution.
Functions of a kernel
1. Accessing computer resources (Use our gpu to play games, watch movies)
2. Resource management (Give CPU time to multiple processes)
3. Memory management (Don’t let chrome hoard our memory, notepad needs it as well)
4. Device management ( Make sure the keyboard types, and other devices work as intended)
4
The responsibilities of a kernel is what makes it such an important component of an operating system. An
operating system is the kernel — plus applications that enable users to get something done, just like the
start menu gives you an option to shutdown your machine “graphically” with an icon rather than making
you type down a system command in a shell window.
4. Device Drivers
The purpose of a device driver is to act as a translator between a hardware device and the applications or
operating systems that want to utilize it. So it simply is a program that operates a particular type of device
which is plugged into the computer. The abstraction provided by the drivers is extremely important,
imagine if you want to make a game, a game is an application. When you are making your game, you
don’t want to think about all the types of input devices being used by the people, and implement a
software solution to “interact” with the hardware everytime you make a game. Besides the code changes
depending upon the platform.
Drivers also require low-level access to hardware functions in order to operate. They usually reside in a
highly privileged environment and can cause many issues if something goes wrong. So you want people
who write this particular piece of code know what they are doing. People at Microsoft have developed a
set of new tools and libraries for driver development called “Windows Driver Frameworks” (WDF) to
minimize system instability due to poorly written device drivers. WDF consists of Kernel-Mode Driver
Framework (KMDF) and User-Mode Driver Framework (UMDF). These individual frameworks provide
a new object-oriented programming model for Windows driver development. Apple has an open-source
framework for developing drivers on macOS, called “I/O Kit”. Linux driver programmers can build
device drivers in different ways. As parts of the kernel, as a separately loadable module or as user-mode
drivers eg. For USB devices.
Virtual device drivers are a special variant of drivers. They are primarily used to “emulate” (reproduce the
function or action of) a hardware device. A key thing to note here is virtual devices can also operate in
non-virtualized environments. Example, a virtual network adapter is used in a VPN (virtual private
network).
If you wish to check which drivers are installed on your computer right now, you can run the following
commands,
Interface : Command
1. Windows Powershell : driverquery
2. Linux Shell : lsmod
3. MacOS Shell : kextstat
5
A thing to note : lsmod the command used for linux, it actually lists all the loaded modules in the kernel
and not all kernel modules are device drivers. Same with MacOS, lists all the loaded kernel extensions not
just the device drivers, the output of this command can be quite overwhelming. You can pip the output of
kextstat into grep *vendor* to find vendor specific kernel extensions.
Eg. kextstat | grep com.apple
Testing device drivers for security is also a very important phase of development, since these drivers run
at high levels of privilege, they can be exploited if found to be vulnerable and can expose the entire
system to a malicious attack.
Driver security checklist by Microsoft:
1. Confirm that a kernel driver is required and that a lower risk approach, such as Windows service
or app, is not a better option
2. Use the driver frameworks to reduce the size of your code and increase its reliability and security
3. If a software-only driver is going to be created, additional access control must be implemented
4. Do not sign development, testing, and manufacturing kernel driver code with a certificate that is
trusted by Windows
5. Either modify an existing driver threat model or create a custom threat model for your driver
6. Review your code and remove any known code vulnerabilities
7. Review your driver to make sure that you are properly controlling access
8. Review technology specific guidance for your driver
9. Review driver inf creation and installation guidance to make sure you are following best practices
10. Perform peer code review, to look for issues not surfaced by the other tools and processes
11. Use code analysis in Visual Studio to investigate driver security
12. Use Static Driver Verifier to check for vulnerabilities
13. Check code with the BinSkim Binary Analyzer
14. Use code validation tools
15. Review secure coding resources
5. Conclusion
Operating systems without a doubt are the bread and butter of computing carried out in our day to day
lives. Complex yet elegant. Understanding them at a deeper level, gives us an insight on the underlying
machinery which powers our work, entertainment and networking with other fellow human beings.
Bootloader is essential to get things fired up, Kernel makes sure everything is running fine and dandy
under the hood, taking care of security and our data — making it the heart of our software system and
device drivers which let you aim with your mouse on the computer screen, making sure that your
computer understands what you are typing while also letting your computer speak / sing a little.
6
References
1. Krzyzanowski, Paul. Rutgers University. Booting an Operating System How do you run that first
program? January 26, 2015
2. Mark Ferlatte, the bootloader description
,
Tue, 6 Nov 2001
3. Ferdous, Javedul & Shekhar, Niladri. (2018). Comparison on Booting Process & Operating
Systems Features. SSRN Electronic Journal. 10.2139/ssrn.3166477.
4. Junaid Jadoon, Faisal Bahadur, IT Department, Hazara University, The Impact of Architecture on
the Performance of Monolithic and Microkernel Operating Systems.
International Journal of
Advanced Research in Computer Science and Software Engineering. ISSN: 2277 128X. June
2015
5. MIT Exokernel Operating System, https://pdos.csail.mit.edu/archive/exo/
6. Lam, Iris. (1998). Overview of the Exokernel Operating System.
7. System Call in OS: Types and Examples
https://www.guru99.com/system-call-operating-system.html
8. Engler, Dawson. (2005). The exokernel operating system architecture,
https://dspace.mit.edu/handle/1721.1/16713
9. Microsoft Windows Driver Frameworks
https://docs.microsoft.com/en-us/windows-hardware/drivers/wdf/
10. Microsoft WDF UMDF, Getting Started with UMDF
, 20 June 2017,
https://docs.microsoft.com/en-us/windows-hardware/drivers/wdf/getting-started-with-umdf-versio
n-2
11. Margaret Rouse, Alex Gillis, Ed Tittel.
https://searchenterprisedesktop.techtarget.com/definition/device-driver
12. List All Third Party Kernel Extensions in Mac OS X
, 3 Aug 2010
https://osxdaily.com/2010/08/03/list-all-third-party-kernel-extensions/
7
ResearchGate has not been able to resolve any citations for this publication.
Article
This paper presents a comparative study of Booting process and features of three popular operating systems. Booting process is the essential and first step perform by the OS after this process execution, all other processes can get the chance to execute, so we may say that booting is the first process because of which all other OS processes can execute. A primary aim of an operating system is to share a computer installation among many programs making unpredictable demands upon its resources which is used various application to manipulate many other resources. Time to time it product some various feature which makes their corresponding operating system unique. During our work, we showed some comparison on features of Windows, MacOS & Linux operating system and point out booting system & its process.
Article
On traditional operating systems only trusted software such as privileged servers or the kernel can manage resources. This thesis proposes a new approach, the exokernel architecture, which makes resource management unprivileged but safe by separating management from protection: an exokernel protects resources, while untrusted application-level software manages them. As a result, in an exokernel system, untrusted software (e.g., library operating systems) can implement abstractions such as virtual memory, file systems, and networking. The main thrusts of this thesis are: (1) how to build an exokernel system; (2) whether it is possible to build a real one; and (3) whether doing so a good idea. Our results, drawn from two exokernel systems [25, 48], show that the approach yields dramatic benefits. For example, Xok, an exokernel, runs a web server an order of magnitude faster than the closest equivalent on the same hardware, common unaltered Unix applications up to three times faster, and ...
Article
The exokernel operating system architecture is an ideology which MIT thinks a efficient and reliable operating systems should be based on. Its goal is to securely give applications efficient control over hardware and software resources by separting protection from management. To achieve customizability and extensibility, exokernel places abstractions traditionally implemented by operating systems, such as virtual memory and inter-process communication, in the user space where user-level libraries abstract exposed resources. This property give applications the flexibility to tailor an operating system that best suit their needs. 1 Introduction Traditional operating systems are usually designed for general purposes. Applications often have to pay penalties for features that they are not using. Traditional OS also place too much restrictions on applications. Information of resources are hidden behind high level abstraction where applications can have no or little access to. This structur...
Mark Ferlatte, the bootloader description
Mark Ferlatte, the bootloader description, Tue, 6 Nov 2001
The Impact of Architecture on the Performance of Monolithic and Microkernel Operating Systems
  • Junaid Jadoon
  • Faisal Bahadur
Junaid Jadoon, Faisal Bahadur, IT Department, Hazara University, The Impact of Architecture on the Performance of Monolithic and Microkernel Operating Systems. International Journal of Advanced Research in Computer Science and Software Engineering. ISSN: 2277 128X. June 2015
Getting Started with UMDF
  • Wdf Microsoft
  • Umdf
Microsoft WDF UMDF, Getting Started with UMDF, 20 June 2017, https://docs.microsoft.com/en-us/windows-hardware/drivers/wdf/getting-started-with-umdf-versio n-2