Operating Systems
Operating Systems
1. Making a computer system convenient to use : An operating system is a layer of software on top of the
bare hardware of a computer system, which manages all parts of the system, and presents to the user
with an interface or virtual machine, which is easier to program and use. That is, the operating system
hides the details of the hardware resources from the programmer and provides the programmer with a
convenient interface for using the computer system.
Users
Other System
Software and Application Programs
Operating System
Computer Hardware
2. Managing the resources of a computer system : The second important objective of an operating
system is to manage the various resources of the computer system. This involves performing such tasks
as keeping track of who is using which resource, granting resource requests, accounting for resource
usage, and mediating conflicting requests from different programs and users. The efficient and fair sharing
of resources among users and / or programs is a key goal of most operating systems.
In addition to the above listed major functions, an operating system also performs few other functions such as
keeping an account of which users (or processes) use how much and what kinds of computer resources,
maintenance of log of system usage by all users, and maintenance of internal time clock.
Measuring System Performance
The efficiency of an operating system and the overall performance of a computer system are usually measured
in terms of the following:
1. Through put : Throughput is the amount of work that the system is able to do per unit time. It is
measured as the number of processes that are completed by the system per unit time. For example, if n
processes are completed in an interval of t seconds, the throughput is taken as n/t processes per second
during that interval. Throughput is normally measured in processes / hour. Note that the value of
throughput does not depend only on the capability of a system, but also on the nature of jobs being
processes, by the system. For long processes, throughput may be one process / hour; and for short
processes, throughput may be 100 processes / hour.
2. Turnaround time : From the point of view of an individual user, an important criterion is how long it taken
the system to complete a job submitted by him / her. Turnaround time is the interval from the time of
submission of a job to the system for processing to the time of completion of the job. Although, higher
throughput is desirable from the point of view of overall system performance, individual users are more
interested in better turnaround time for their jobs.
3. Response time : Turnaround time is usually is usually not a suitable measure for interactive systems,
because in an interactive system, a process can produce some output early during its execution and can
continue executing while previous results are being output to the user. Hence, another measure used in
case of interactive systems for processing to the time the first response for the job is produced by the
system.
In any computer system, it is desirable to maximize throughput and minimize turnaround time and response
time.
Process Management
A Process (also called job) is a program in execution. The main objective of the process management module
of an operating system is to manage the processes submitted to the system in a manner to minimize the idle
time of the various processors (CPU, I/O processors, etc.) of the computer system. In this section, we will learn
about some of the mechanisms commonly used in modern operating systems to achieve this objective. We will
also see how these mechanisms have gradually evolved from the early days of computers.
The same process had to be repeated for every job to be executed by the computer. This method of job
execution was known as the manual loading mechanism because the job had to be manually loaded one
after another by the computer operator in the computer system. Notice that in this method, job-to-job
transition was not automatic. The manual transition from one job to another caused lot of computer time to
be wasted since the computer remained idle while the operator loaded and unloaded jobs and prepared
the system for a new job.
In case of batch processing systems, job were typically executed in the following manner:
1. Programmers would prepare their programs and data on decks of cards or paper tapes, and submitted
them at the reception counter of the computer centre.
2. The operator would periodically collect all the submitted programs and would batch them together and
then load them all into the input devices of the system at one time.
3. The operator would then give a command to the system to start executing the jobs.
4. The jobs were then automatically loaded from the input device and executed by the system one-by-one
without any operator intervention. That is, the system would read the first job from the input device,
execute it, print out its result on the printer, and then repeat these steps for each subsequent job, until all
the jobs in the submitted batch of jobs were over.
5. When all the jobs in the submitted batch processed, the operator would separate and keep the printed
output of each job at the reception counter for the programmers to collect them later.
Multiprogramming
Main memory
In case of both manual loading and batch
processing of jobs, the jobs are loaded into the Operating system OS area
system and processed one at a time. That is,
Execution in
once loaded, a job will remain in the main
progress
memory until its execution is completed and the User
User job Program
next job will be loaded only after the completion
area
of the previous job. As shown in figure 14.3, in
such a situation, the job, which is currently
loaded and is being executed, will be the sole
occupant of the user’s area of the main memory CPU
(the operating system always resides in a part of Fig. A uniprogramming system model in which only one job
the main memory) and it will have the CPU is processed by the system at a time and all the system
exclusively available for itself. The situation resources are exclusively available for the job until it
shown in figure 14.3 is that of a uniprogramming completes.
system in which only one job is processed at a time and all the system resources are exclusively available for
the job until it completes.
1. CPU-bound jobs. These jobs mostly perform numerical calculations, with little I/O operations. They are
so called because they heavily utilize the CPU during the course of their processing. Programs used for
scientific and engineering computations usually fall in this category of jobs.
2. I/O-bound jobs. These jobs perform very little computation and most of the time they perform I/O
operations. Hence, their CPU utilization is very low. Programs used for commercial data processing
applications usually fall in this category of jobs.
Multiprogramming is the name given to the interleaved execution of two or more different and independent
programs by the same computer. In figure 14.3, we have been introduced to the notion of having two programs
in the main memory at the same time – the operating system for overall system control and the user program
for performing user’s job. In multiprogramming, this concept is carried one step further by placing two or more
user programs in the main memory and executing them concurrently.
It is important to note here that multiprogramming is not defined to be execution of instructions from several
programs simultaneously. Rather, it does mean that there are a number of programs available to the CPU
(stored in the main memory) and that a portion of one is executed, then a segment of another, and so on.
Although two or more user programs reside in the main memory simultaneously, the CPU is capable of
execution only one instruction at a time. Hence at any given time, only one of the programs has control of the
CPU and is executing instructions. Simultaneous execution of more than one program with a single CPU is
impossible. In some multiprogramming systems, only a fixed number of job can be processed concurrently
(multiprogramming with fixed tasks) (MFT), while in others the number of jobs can very (multi programming with
variable tasks) (MVT).
Main memory Job is allocated the
Writing
output Operating system New CPU for execution
Ready Running Job
Execution in
data job
progress
Job A processing
completed
Job B
Job C I/O
(waiting for CPU) completed Job must wait for
Secondary I/O completion
disk storage CPU
Blocked
Fig. A typical scenario of jobs in a
multiprogramming system. Fig. The three different states in which jobs
may be after getting loaded in the main
memory in a multiprogramming system.
Process state
Program counter
Values of various
CPU registers
Accounting and
scheduling information
I/O status information
Y
Multitasking
Technically speaking, multitasking is the same as multiprogramming. That is, multitasking is the system’s
capability to concurrently work on more than one task (job or process). This means that whenever a task (job or
process) needs to perform I/O operations, the CPU can be used for executing some other task (job or process)
that is also residing in the system and is ready to use the CPU.
Many authors do not distinguish between multiprogramming and multitasking because both the terms refer to
the same concept. However, some authors prefer to use the term multiprogramming for multi-user system
(systems that are simultaneously used by many users such as mainframe and server class system), and
multitasking for single –user systems (systems that are used by only one user at a time such as a personal
computer or a notebook computer). Note that even in a single-user system, it is not necessary that the system
the system work only on one job at a time. In fact, a user of a single-user system system often has multiple
tasks concurrently processed by the system. For example, while editing a file in the foreground, a sorting job
can be given in the background.
For those who like to differentiate between multiprogramming and multitasking, multiprogramming is the
concurrent execution of multiple job (of same or different users) in a multi-user system, while multitasking is the
concurrent execution of multiple jobs (often referred to as tasks of same user) in a single-user system.
Multiprocessing
Up to this point, we have considered systems with a single CPU. However, we have already seen that the use
of I/O processors improves the efficiency of a computer system by making possible concurrent input,
processing and output operations. The CPU can perform arithmetic and logical operations on parts of one or
more programs, while I/O operations are concurrently carried out by I/O processors on other parts of programs.
Figure 14.7 shows the architecture of a computer with its CPU, memory and I/O processors.
Main memory
Fig. Architecture of a computer system showing its CPU, memory and I/O processors.
The idea to use I/O processors to improve the performance of a computer system was carried one step further
by designing systems that make use of more than one CPU. Such system are called multiprocessing systems.
The term multiprocessing is used to describe interconnected computer configurations or computers with two or
more CPUs, which have the ability to simultaneously execute several programs. In such a system, instructions
from different and independent programs can be processed simultaneously by different CPUs, or the CPUs
may simultaneously execute different instructions from the same program.
Time-sharing
Time-sharing is a mechanism to provide simultaneous interactive use of a computer system by many users in
such a way that each user is given the impression that he/she has his/her own computer. It uses
multiprogramming with a special CPU scheduling algorithm to achieve this.
A time-sharing system has many (even hundreds of) user terminals simultaneously connected to the same
computer. Using these terminals, multiple users can simultaneously work on the system. The multiprogramming
feature allows multiple user programs to simultaneously reside in the main memory. The special CPU
scheduling algorithm, used in a time sharing system, allocates a very short period of CPU time one-by-one to
each user process, beginning from the first user process and proceeding through the last one, and then again
beginning from the first one. This short period of time during which a user process gets the attention of the CPU
is known as a time slice, time slot, or quantum and is typically of the order of 10 to 100 milliseconds. That is,
when the CPU is allocated to a user process, the user process will use the CPU until the allotted time slice
expires (the system’s clock sends an interrupt signal to the CPU after every time slice), or until the process
needs to perform some I/O operation, or if the execution of the process is over during this time period. Notice
here that in a time-sharing system, the CPU is taken away from a running process when the allotted time slice
expires, even though the process can continue to run. Hence, the process state diagram of a time-sharing
system is as shown in figure 14.9 (compare this with the process state diagram of figure 14.5)
I/O
completed Job must wait for
I/O completion
Blocked
Offer good computing facility to small user. Small can gain direct access to much more sophisticated
hardware and software than they could otherwise justify or afford. In time-sharing systems, they merely pay a
fee for resources used and are relieved of the hardware, software, and personal problems associated with
acquiring and maintaining their own installation