The operating system is the first piece of software to run on a computer when it
is booted. Its job is to coordinate the execution of all other software, mainly user
applications. It also provides various common services that are needed by users and
1.1 Operating System Functionality
The operating system controls the machine
It is common to draw the following picture to show the place of the operating system:
This is a misleading picture, because applications mostly execute machine instructions that do not go through the operating system. A better picture is:
where we have used a 3-D perspective to show that there is one hardware base, one
operating system, but many applications. It also shows the important interfaces: applications can execute only non-privileged machine instructions, and they may also
call upon the operating system to perform some service for them. The operating system may use privileged instructions that are not available to applications. And in
addition, various hardware devices may generate interrupts that lead to the execution of operating system code.
A possible sequence of actions in such a system is the following:
1. The operating system executes, and schedules an application (makes it run).
2. The chosen application runs: the CPU executes its (non-privileged) instructions,
and the operating system is not involved at all.
3. The system clock interrupts the CPU, causing it to switch to the clock’s interrupt
handler, which is an operating system function.
4. The clock interrupt handler updates the operating system’s notion of time, and
calls the scheduler to decide what to do next.
5. The operating system scheduler chooses another application to run in place of
the previous one, thus performing a context switch.
6. The chosen application runs directly on the hardware; again, the operating system is not involved. After some time, the application performs a system call to
read from a file.
7. The system call causes a trap into the operating system The operating system
sets things up for the I/O operation (using some privileged instructions). It then
puts the calling application to sleep, to await the I/O completion, and chooses
another application to run in its place.
8. The third application runs.
The important thing to notice is that at any given time, only one program is running.
Sometimes this is the operating system, and at other times it is a user application.
When a user application is running, the operating system loses its control over the
machine. It regains control if the user application performs a system call, or if there
is a hardware interrupt.
Exercise 1 How can the operating system guarantee that there will be a system call or
interrupt, so that it will regain control?
The operating system is a reactive program
Another important thing to notice is that the operating system is a reactive program.
It does not get an input, do some processing, and produce an output. Instead, it is
constantly waiting for some event to happen. When the event happens, the operating
system reacts. This usually involves some administration to handle whatever it is
that happened. Then the operating system schedules another application, and waits
for the next event.
Events can be classified into two types: interrupts and system calls. These are
described in more detail below.
The goal of the operating system is to run as little as possible, handle the events
quickly, and let application run most of the time.
Exercise 2 Make a list of applications you use in everyday activities. Which of them
are reactive? Are reactive programs common or rare?
The operating system performs resource management
One of the main features of operating systems is support for multiprogramming. This
means that multiple programs may execute “at the same time”. But given that there
is only one processor, this concurrent execution is actually a fiction. In reality, the
operating system juggles the system’s resources between the competing programs,
trying to make it look as if each one has the computer for itself.
At the heart of multiprogramming lies resource management — deciding which
running program will get what resources. Resource management is akin to the short
blanket problem: everyone wants to be covered, but the blanket is too short to cover
everyone at once.
The resources in a computer system include the obvious pieces of hardware needed
• The CPU itself.
• Memory to store programs and their data.
Download the pdf file to get all the unit wise notes.
Try to save your valueable time!