Operating System 347
The OS is also responsible for optimizing the hardware resources. Even for a single-user system, all
modern computers implement multi-tasking (executing more than one program at a time). An example
of multi-tasking may be the concurrent printing of some word document, which you have just nished,
although during this ongoing printing process you use the same computer to surf the net (internet I
mean). You need not wait for your printing operation to be completed to start the sur ng operation. All
these are possible because of the present status of evolution of OS, and to understand where we stand
today, we have to look back a little.
11.1.3 Evolution of OS
At the very early stage of computers there was no OS at all. The developer of a computer had been its
sole user. The whole affair was something, e.g., setting several hundreds of jumper connections and set-
ting up many more potentiometers (variable resistances) to make the whole system work to solve one
particular differential equation, which is of interest to the programmer. In a nutshell, the then program-
mer was forced to interact directly with the hardware.
The situation marginally improved at a later stage of development, so that instead of executing only
one user program, the system became capable of executing several programs, one after another. These
programs (designated as jobs) were supplied in the form of punched cards and after placing them on
the punch-card reader, the operator has to evoke a few commands to start its execution. Those few com-
mands were the starting of the OS and the scenario described was designated as batch processing . Note
that we still use the same name in form of .bat le extension.
At this stage, people started realizing the advantage of an OS, which would relieve the programmer from
the additional burden of interacting directly with the computer hardware. However, earlier OSs were very
primitive, little more than simple BIOS. The BIOS, as we know, contains some very basic program segments
to interact with the computer hardware, which too was very elementary at that stage. The more complex the
hardware became, the more coverage was from the OS, culminating to the present day one, where the user
has to just move a pointer using the mouse and click an icon displayed on the screen to get some job done.
11.1.4 Purpose of OS
So, now, we may relax and take a stock of the situation, about what it was and what it is. It is not true
that only the OS has made computers more user-friendly. Equal share must also be credited to the devel-
opment of computer hardware. In general, people are either biased about software or about hardware,
without realizing that they are like two wings of a bird and without any one , the other becomes useless.
Therefore, the very purpose of the OS is to free the user and application software from the burden of
interacting directly with the computer hardware. To achieve this, we have to understand various aspects
of OS, and the fundamental one is process control, which we shall discuss now.
11.2 PROCESS AND ITS CONTROL
What is a process? In terms of OS, a process is a program or program segment that is presently being
executed by the processor or to be executed very soon. Note that the hard disc (or any other similar sec-
ondary storage device) of a computer may already have thousands of application programs. From OS’s
point of view, they are only programs and not process. OS would designate it as a process if its execution
is necessary, now or very soon. As we already know that a processor can execute any program only if it is
available in its main memory, therefore, we may assume that a process should be available in that location.
M11_GHOS1557_01_SE_C11.indd 347M11_GHOS1557_01_SE_C11.indd 347 4/29/11 5:21 PM4/29/11 5:21 PM
348 Computer Architecture and Organization
11.2.1 Multi-tasking Environment
Throughout the discussions of the present chapter we must remember that modern OSs are designed
for multi-tasking. What is meant by multitasking? It means that more than one process is considered
for execution. Does it mean that we are considering multiprocessor based systems, the computers with
more than one processor? No, we are not. The computers that we are discussing are basically PC-type
with only one processor. Then how would the processor execute multiple processes simultaneously? We
know that any processor executes only one instruction at a time. True! However, the general trend is to
look after several processes, allowing each one a small time-slice, say of several milliseconds. That is,
after executing several instructions of a process, the processor temporarily discards that process (leaves
aside) and attends to another process. Because of very fast switching from one process to another, an
illusion is created for the user that all processes are running concurrently.
As an example case, take the following scenario. Assume that you are using your word processor
to write a technical article. Assume that at one stage you decided to search in the internet for the exact
de nition of a technical phrase. You would then click-open the search engine and evoke a search at such
a stage. When your PC is busy in locating that phrase in the net, it is also allowing you to further type
your un nished article, look after its spell-check and update the display as and when necessary. Observe
that net-searching, key-reading, spell-checking and display-updating are all going on in full swing.
However, at the micro-level, the processor is still executing one instruction at a time.
Multi-tasking gives us the best throughput as the processor is never allowed to sit idle. Had the pro-
cessor been given only one task of, e.g., key reading, assuming the keyboard was interfaced through
USB port, it would have issued only one frame at every millisecond (USB communication in Chapter 8)
and during the remaining time of that millisecond it would have been sitting idle. In this chapter, we
concentrate on this multi-tasking environment as far as the OS is concerned.
11.2.2 Life-cycle of a Process
Schematically, the life-cycle of a process is depicted in Figure 11.2 . As we may observe, right after
its generation, a process is placed within a long-term queue . What is meant by the term ‘generation’?
It means that the process is identi ed, given a suitable number for the purpose of its identi cation in
future, its process control block (PCB) is created (we shall discuss in Section 11.2.3) to hold its relevant
information, and politely requested to take the back seat of the long-term queue.
From the long-term queue, a process is allowed to enter in the short-term queue only when a vacancy
is created. During an on-going scenario, this vacancy is created whenever another process is nished and
leaves the arena through the exit door (indicated in the bottom-most block of Figure 11.2 ). The average
waiting within the long-term queue may be in seconds or sometimes in minutes. However, the average
Even if you are using only your word processor program, the environment is a multi-tasking
one. You can go for printing your saved document and keep on editing your present document
concurrently. Remember that during editing, key reading, display refreshing and spell-check
routines are being executed concurrently.
F
O
O
D
F
O
R
T
H
O
U
G
H
T
M11_GHOS1557_01_SE_C11.indd 348M11_GHOS1557_01_SE_C11.indd 348 4/29/11 5:21 PM4/29/11 5:21 PM
Operating System 349
waiting time within the short-term queue is, generally, in milliseconds. From the short-term queue, a
process is allowed to be executed by the processor whenever the processor is free and the process is
closest to the processor within the short-term queue (exceptions are there, but we are avoiding those
cases at present). In Figure 11.2, we observe that there are three outgoing tracks from the processor.
The rst one we have already discussed, that is the process-termination route. The second one is due to
some I/O request by the on-going process itself. Generally, I/O procedures are time-consuming and as
the processor does not like to sit idle and wait for it to be nished, the I/O requesting process is shown
another queue, the I/O queue, where it may wait till the completion of its I/O requirement. Once its I/O
requirements are satis ed, the process re-enters into the short-term queue and waits for the processor
time. The third route sends the process back to the short-term queue directly. What is the reason behind
it? Well, it is because of the interrupt from the OS itself. Why these interrupt? This is because, the OS
does not want to allow any process an in nite time to complete its execution. Rather it offers every
process a prede ned time-slice, e.g., 10 or 20 milliseconds, after which the next process from the short-
term queue must get its chance to interact with the processor.
Therefore, before its termination, any process oscillates between the processor and the short-term
queue several times and always gets a limited time to encounter the processor. In a nutshell, this is the
life cycle of a process.
11.2.3 Process Control Block (PCB)
As indicated above, a process is created by creating its PCB. Apart from an unique process number, it
contains the value of the program counter, names and conditions of all processor-registers being used,
name of data les being associated with the process, if any, and some other conditions for smooth
Figure 11.2 Life-cycle of a process
[Process terminated]
[Process generated]
Execution
(by processor)
M11_GHOS1557_01_SE_C11.indd 349M11_GHOS1557_01_SE_C11.indd 349 4/29/11 5:21 PM4/29/11 5:21 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.164.24