Operating System
Operating System
1 Early Systems
There was no operating system on the first computer systems. The operator of the computers had direct access
to the computer hardware. He/she directly manipulates the resources of the computer without any intermediate.
From the second half of the 1940th to the 1950th, the computers had more or less the following features.
Programs were entered using plug boards or punched cards. The results of the computation were given on
printers. There were a memory unit used to store both data and program. The operator of those machines was
also the programmer, and maintained the computer whenever there was a problem. At the execution of the
program, the programmer/operator could monitor the execution; for example, he could stop the execution of the
program whenever he wants to see the state of the machine on the display lights. There was no operating
system.
Execution Program 1 Execution Program 2
Executing
There were two important problems with those machines. First, since the programmer had to use directly the
machine language and had to control directly all devices of the computer, program writing was a very difficult
Setting
task. Second, the CPU, the most expensive Read ofOutput
Readcomponent Read
the computer, was underSetting
utilized since Read
it was idle
mostIdle
of the time. Indeed, the CPU was much faster than the Input/Output devices and setting up the system for
Time
the execution of a new program takes time. For example, a slow CPU works in the microseconds range (1
million instructions a second). The fastest card reader can read 17 cards (instructions) a second; thus the
computer needs 58,828 microseconds to read an instruction that it will take only a microsecond to execute.
2 Batch Systems
The Batch System computers that prevailed from 1955 to 1965 attempted to solve the problems of the previous
systems using simple techniques. First, to limit the setup time, an operator was assigned to take program cards
from programmers and put them in the card reader. As the operator was specialized in what he does he wastes
less time in the setup. Since many programs are loaded at the same time the setup time decreases considerably.
However, this doesn't limit the time between two card readings. However, he latest Batch Systems computers
started to use magnetic tapes; reading an instruction from a tape was much faster since it requires only around
20 microseconds. To reduce programming difficulty high level programming languages started to make their
appearance (COBOL, FORTRAN, etc.). In order to separate one batch program from the next one, control
cards were inserted between the two program's cards. Those cards can be considered as the first ancestors of
today's operating systems.
Control Card
Executing
Setting Read Read Output Read Read Read Read Read Read
Idle
Time
3 Spooling
Around 1965, computer systems that use spooling started to appear. These computers try to limit the I/O
waiting time of the previous systems by doing I/O operations concurrently with processing. I/O channels deal
with I/O independently from the processor. If an output device can get its information from memory and
perform output without the processor directing the action, output can occur concurrently with processing.
Similarly, if an input device can place information into memory without processor intervention, input and
processing can occur concurrently. Whenever the attention of the CPU is required for an I/O channel, it sends
an interrupt that will inform the CPU about it.
The advent of disk systems allowed high flexibility in spooling. The jobs coming as input arrived sequentially
but could be stored temporarily on disk. A scheduler then selects a job from the pool in any desired order.
Similarly jobs being pooled for printing could be printed at convenience. The lock-step of sequential response
brought about by the nature of the card reader was broken. The operating system of spooling systems was of
course more complicated than the embryo of operating system found in the previous systems.
Output
Control Card
Executing
Setting Read Read Read Read Read Read Read Read Read
Idle
Time
Figure: CPU execution time for computers using spooling
4 Multiprogramming
With spooling only I/O channels could send interrupts. This has changed with multiprogramming where
application programs could also send interrupts. This enables switching from one program to another. With
multiprogramming, when a program A under execution is suspended pending an I/O operation, the processor
can change focus on another program B which is also in memory until an interrupt occurs. The processor will
eventually return to program A. Prior to multiprogramming I/O activities of a program could occur concurrently
with the processing of the same program. With the advent of multiprogramming I/O of one program was
allowed to overlap with processing of another program.
Input Program 1
Input Program 2
Control Card
Executing
Idle
Time
Figure: CPU execution time for computers using multiprogramming
5 Time Sharing
One big drawback introduced by batch systems was that users do not interact with their programs. Time sharing
introduced along with multiprogramming enabled each program to acquire the CPU regularly for a small slice
of time. The operating system switches processing from one user program to another. The processor is so fast
compared to the I/O devices and users, enough work can be done during that short slice of time to give the user
the impression that the entire system and its resources belong to him or her alone.
Execution of Program 1
Execution of Program 2
Execution of Program 3
Executing
Idle
Time
6 Microcomputers
The evolution of operating system seen above concerns mainly the large mainframes and other multi-user
computers. At the end of the 1970s, microcomputers made their appearance. They were much smaller and less
expensive than the multi-user computers. Instead of maximization of the CPU utilization, user convenience and
responsiveness were privileged.
In the first years, all microcomputers were single user, single tasking. In the mid-1980s, many single user,
multi-tasking operating systems were developed for microcomputers. In the 1990s, operating systems as
sophisticated as the mainframe operating systems started to be developed for personal computers (UNIX,
Windows NT, etc.).
The communication problem between personal microcomputers has led to the development of networking
hardware and software. Initially separate software packages were introduced to add networking features to the
existing operating systems. But the latest operating systems have included networking features as an integral
component.
4 Windows NT
Windows NT has been designed in the early 1990s to offer a high-end operating system for personal computers
(Intel and Alpha processor based) with security, protection and reliability features. Windows NT is a server
based operating system requiring high amount of memory (at least 16 MB) and fast processor. Windows NT
has inherited from Windows 3.1 its user interface. Later on Windows NT 4.0 has been developed with
Windows 95 interface. Windows NT is also upward compatible with MS-DOS and Windows 3.1.
It is planned that Windows 95 and Windows NT will merge in the future and form a single operating system.
The requirements of Windows NT are already becoming acceptable for most PC owners. The main factor that
probably makes users prefer Windows 95/98 to Windows NT is probably its high price.
1 Monolithic Systems
With operating systems that have adopted the monolithic organization, the operating system is written as a
collection of procedures, each which can call any of the other ones whenever it needs to. Each procedure has a
well defined interface in order to allow the programmer to use it in the development of other procedures. Even
with the monolithic systems, there are some structures. Generally, there is a main procedure that can be invoked
from application programs. Whenever the main procedure is called it invokes service procedures or also called
system calls. The system calls call utility procedures that can call directly the computer hardware.
Main Procedure
System Calls
Utility Procedures
2 Layered System
The Layered Systems organize the operating system in a number of layers, each constructed on top of the other.
For example, the THE system designed by Dijkstra (1968) structures the operating system into 6 layers (Figure
below). Each layer handles a specific task of the operating system. For example, layer 0 handles process
allocation and multiprogramming, layer 1 Memory and drum management, ...
Layer # Task
5 The Operator
4 User programs
3 Input/Output
2 Operator-process communication
1 Memory and drum management
0 Processor allocation and multiprogramming
Figure: Structure of the THE system
A further generalization of the layering concept was present in MULTICS system. Instead of layers, MULTICS
was organized as a series of concentric rings, with the inner ones more privileged than the outer ones.
3 Virtual Machines
A timesharing operating system can give the illusion of multiple processes, each executing on its own processor
with its own virtual machine. The virtual-machine approach provides several Virtual Machines identical to the
underlying bare hardware without any additional feature such as a file system. The resources of the virtual
machine are shared to create the virtual machines.
Hardware Hardware
Figure: System models (a) Non virtual machine (b) Virtual Machine
The virtual machine concept has several advantages. First, since each machine is completely isolated from all
other machines, there is a complete protection. Second, this is a perfect vehicle for operating systems design
since it is possible to run the operating system under design on the virtual machine and a full machine is not
required for the research.
It has also some drawbacks. For instance, sharing of resources is difficult since the virtual machines are
completely isolated. However, two approaches have been developed for resource sharing of the operating
systems that support the virtual machine concept. First, it is possible to share the disk space. Second, it is
possible to define a network of virtual machines.
4 Client-server model
A trend in modern operating systems is to remove as much as possible from the operating system and to leave a
minimal kernel. Most of the operating system functions will be implemented in user processes. To request a
service, such as reading a block of a file, a user process (known as client) sends a request to a server process,
which then does the work and sends back the answer. One advantage of the client server model is its
adaptability to use in distributed systems.
.VI Summary
Operating Systems are invented to make better use of the computer hardware and to give a convenient interface
to the users. They have evolved considerably during the last four decades. Today's operating system are for
most multi-user, multi-tasking, with graphical interface and possesses various tools such as network software
tools.
It is impossible to design and implement an operating system, which is a large software, without having a
certain structuring method. There are various models for the structure of operating systems. The main four
models are: monolithic structure, layered structure, virtual machines and client server structure.
Process Management
.I Introduction
All modern operating systems can execute several tasks at a time (Windows 95, Windows NT, UNIX, etc.).
This allows them to use efficiently the resources of the computer, especially the processor. It also gives
convenience for the user, since he/she doesn't need to wait for the end of the execution of a program before
starting the execution of another program.
Early computer systems allowed only one program to be executed at a time. This program had complete control
of the resources of the computer system. Current-day operating systems allow several programs to be in
memory and execute concurrently. The same program can be run by two different users almost simultaneously.
This has necessitated the notion of process which is a program in execution.
A process is a unit of work. Every work (user or system) is accomplished on a computer using one or several
processes. On modern systems, these processes run concurrently using time sharing concepts.
The concept of executing several processes concurrently seems new but humans are used to execute tasks
concurrently in a way very similar to what operating systems do. For example, a mother can bake a cake and
take care of her child at the same time. While she is baking the cake using a recipe her child can cry because he
has fallen down and he is bleeding. She will obviously stop baking the cake and take care of her child by
following instructions on a medical care book and using a first aid kit. When she finishes the first aid care she
will go back and finish baking right from where she stopped. In this example, there are two jobs done
concurrently and the following important observations can be made:
1- The mother uses a program (recipe or medical care book) to perform her jobs
2- The mother can perform only one job at a time but she can also perform several jobs by switching
from one job to another
Ready Running
Scheduler
Dispatch
I/O or event I/O or event
Completion Wait
Waiting
4 Process hierarchies
Operating systems that support the process concept must provide some way to create and destroy the processes.
A process is generally created by an existing process upon executing a system call (usually called fork). The
creator of the process is called the parent while the process newly created is called the child.
In UNIX, the child is almost identical to the parent. It has the same code, an identical copy of the data and stack
segment. The child executes the code exactly from where the parent called the fork.
The parent and the child can create several child processes. It is therefore possible to have a whole tree of
processes.
5 Context switch
Switching the CPU from one process P1 to another process P2 requires saving the values of all the registers in
the PCB of P1. This is because all the values should be restored when P1 is given once again the CPU. Then,
the values of the registers at the end of the previous execution of P2 will be loaded from its PCB into the
register before P2 can start running. This task of saving the data in CPU of the process that is leaving and
bringing the data of the newly selected process into the CPU is called context switch.
Process switch time is an overhead (1 to 1,000 micro-seconds). It depends on the speed of the processor, the
number of registers to save, etc. This overhead should be taken into consideration in the design of the
scheduler.
1 Scheduling queues
For a uniprocessor system, at one given time, only one process can get the CPU. The other will be put in
various queues (waiting list). There are a number of queues.
a) The ready queue
All processes in the ready state will be put in the ready queue. This queue is generally stored as a linked
list. The elements of the linked lists are the PCBs of the processes.
b) The I/O device queue
A process may need the service of a certain device (disk for example). Since there are many processes
in the system the device may be busy in executing the request of some other process. Of course, the
process cannot run and has to wait for that particular device. The list of processes waiting for a
particular device is called a device queue. Each device has its own device queue.
A common representation for discussion of process scheduling is a queuing diagram (Figure). Each rectangular
box represents a queue. Two types of queues are present: the ready queue and the device queues. The circles
represent the resources that serve the queue and the arrows indicate the flow of the processes in the system.
CPU
Ready Queue execut
es
I/O
execut I/O Queue I/O Request
es
Time slice
expired
4 Quantum
With time sharing operating system there is a slice of time, called quantum, during which the process can run
without being interrupted by the operating system. If the process has still not finished its execution or is not
blocked during that slice of time, the operating system interrupts the execution of the process and gives the
CPU to some other process.
One of the most important decision that should be made during the design of an operating system is the length
of the quantum. Suppose the context switch takes 5 ms. If a quantum length of 20 ms is use, 20% of the CPU
time will be used for the overhead. Suppose that the quantum is set to 500 ms. Less than 1% of the CPU time
will be used for the overhead. However, setting large quantum has also other drawbacks; for example, it limits
the switching between processes and the user will not have the impression that the machine is only use by him
or her.
Many processes can now exist within a single process. Threads within a single process share the same resources
but have their own threads of controls. The key benefit of threads derive from performance implications. It
takes less time to create and terminate a thread. It also takes less time for inter-thread communication as well as
switching from one thread to another. However, these benefits do not come without drawbacks. Since the
resources are shared without the intervention of the operating system, the programmer has to explicitly manage
the resources shared between the threads.
.V Summary
The process is a central concept in operating system. It consists of a program in execution. The PCB stores all
information on the process. This information is used by the operating system for scheduling and context switch.
There are a number of scheduling algorithms that are suitable for various situations. However, there are a
number of goals such as fairness, response time, efficiency that the designer of a scheduler should have in
mind.