OS Q&Ans UNIT 1
OS Q&Ans UNIT 1
C-3
Whatis batch operatin system?
The
operating systems
ing systems of
or these
the
times were
INTRODUCTION imilar jobs very slow and
Unit 1 the processing similar
peoperator wo
were
run each batch.
grouped together
The
in the
simple.
form of batches and
To Speed
SECTION A
output of each
batch was then sent back
o programmer
1) Program Execution
(iv) Information Management functions
2) I/o Operations
Q.3 List the function and services provided by an operating system. File System Manipulation
3)
Dec.2004
Services Provided by an Operating System calls$?
are:
Q.8 What are system
() Program Execution interface between a process and the operating
System Calls provide the
on their usage.
(ii) 1/0 Operations system. System calls can be classified depending
(ii) File System Manipulation
(iv) CommunicationsS 9.9 What is parallel receiving as parallel in operating system
The data will be sending and
(v) Error detection
(vi) Resume Allocation program? the
Q.10 What is system
system programs
are found
between
where there are a large number of events, mostly external to the times Ex: Guided hissile systems
and
De
responded and system ana system?
processed in a short time or within certain dead lines. These operating Dec 2010, 2009
ofsystems are used only in dedicated
control, telephone switching
type
applications. Such applications include indust
equipment, flight control and real time
12 12 What is m u l t i p r o g r a m m i n g
Nov 2016,
2012,
simulations
Neera)'s THH Bemester CA
g ByAlamy
yslem ier, a
egister set
Ihem shae tn ar& star
data, the , ees
Program
P r o r e s a
nD communication
S Ommucaton
involves sending information
Nov 2015, 2011 or the CPU time for executlon In first come first serve" method.
h . hs from one proc
on Deaeievad usng many
w h enaves e a methods such as
maildox >y* Q22 What is FCFS scheduling?
vtua
ommunications network, or use
First-come-first-serve (FCFS) Is a simplest scheduling algorithm.
Here the
througn is allocated the CPU first processes are dispatched
Ocess that request the CPU First,
7 Waat is thread? Wite any acc to thelr arrival time on the ready queue
i.e. requests are scheduled in
one rding
advantage.Nov 2011, De 2010 the order in which they arrive the system.
a t i n gS Y s t e m s
C-6
C-7
Increased perfornma
dispatcher. ance, since
0.23 Define the terms scheduler and Nov 2015 (a)
P rprevious
e job job finished it was
A scheduler is a software product that allows an enterprise to schedule 3sl0le for
and scheduling is very simple
job to start as scan as
work include running
computer batch tasks. These units of a securitu
(b)
track
trd program
or updating software.
(c)
Provides
simple forms of
A dispatcher is a person who handles the tlow of information, people, and pisadvantages: file-management
from a centralized headquarters. Turn round
equipment time can be
(a) large from users
Nov 2012, May-2005 difficult to debug point
Q.24 What is context switching?
(b) More
the of view
program
in a multi programming environment it is necessary to move from one procece job could be enter in
to another. Switching the CPU to another process requires the saving state ofthe
(c) A a
infinite LOOP
Beacuse of slov I/0 devices, the CPU
d)
old process and loading the saved state for the new process. This process is known is often idle.
as context switching.
plainmulti-programming system. Mention its
Context switch time is pure over head, because the system does no useful advantages.
work while sitching context switching is highly dependent on the hardware
support aoal of multiprogramming is to improve the
The
Nov 2016
On the other hand, the decision of how long the timer is set for a particular user It usually support multiple users, in which case they are also called multi
is a policy decision. Systems. Multiprogramming increases CPU utilization by organising jobs
1&F such
Utilization: In utilized.
I m p r o v e d Memory is optimally
(vi) Real time system ogram resides in main memory.
Thus memory
disadvantages.
Q.2 What is batch processing system? Give its advantages and Give its
advantages and
Nov 2017, 2015
disadvatages.
9.4 Wh
i s time sharing
system?
tne s a m e
computer
worK On
to
ne of users system tends
operating systems of these times very slow and simple. To speed
were allowsa
number
in a
t i m e - s h a r e d
ne processing similar jobs were grouped together in the form of batches Atime-sharing system command
Ine SWitching
between
ne
operator would run each batch. The anu the same time. Since each
action or
allotted
for each
user.
to programmer. output of each batch was then sent Das be Only a little CPU time
is
e r a l i n gS Y s t e tems
power supplier
(b) There is a limit allocated for each even.
(b) Increase reliability.
(c) Implementation is too costily.
Disadvantages:
(a) Implementation is complex 0.8 Discuss the various functions of the Operating System.
Dec 2013, 2009, Feb-2002
(b) Require resource management and protection
Functions of Operating Systems are:
Q.6 What is distributed system? Give its advantages and disadvatages. Functions:
(i) Memory Management
The processors do not share memory or a clock. Each
processor has its own Keep track of the memory.
local memory. The processors communicate with one another
through various memory, when is gets
Communication line such as buses or telephone lines. These
-
when any
Deal cate the processor
Disadvantages:
- Implementation complex
(n)Device Management Function:
control units.
channels,
the devices,
Keep track of
e r a t i n gs Y s t eMS
m
Neeraj's Third Semester CA
C-10 Scann
Allocate the device
and initiate the I/0 Operation.
(8) Main Memory
Aanagement: Ma C-11
-
etc of
physical media.
information on severa d fferent
Keep track of the information in allocating and deallocatino p e s
The operating systems have evolved gradually over the years, in recent
5) Management
6) Networking.
a number of design new design elements have be introduced into them years, 7) Protection System.
multi processor machines, increased machine speeds, high speed networe as
orks and a 8) Command Interpreter System.
variety of memory storage devices. Ihe evoution or modern
operating systems .
are:
Personal
Explain the service provided by the operating
system.
Network
Computing OS Nov 2015, Dec 2010
An operating system provides an environment for the execution of programs
System software
Time Human computer arovides certain services to the programs and to
the of those
Shaning interface
users
programs.
The services are as follows:
Model
scheduln Clier Embedded 1) Program execution: The system must be able to load a program
into
an g,pemrmoatenecntgtioemnent
OS
memory and to run that program. The program must be able to end its execution,
scheduling
Real
time
either normally or abnormally (indicating error).
2) 1/0 operations: A running program may require 1/o. This 1/0 may involve
a fle or an I/0 device. For specific devices, special functions may be desired For
Memory efficlency and protection; users usually cannot control I/0 devices directly. Therefore,
Batch management the operating system must provide a means to do I/0.
Modern Network storage Small
protection files OS Resource Computer 3) File system manipulation: The file system is of particular interest.
scheduling9 management
Obviously, programs need to read and write files. Programs also need to create and
error or a
computing.
appropriate read and write
ensure
action to users are logged on to sv Dlain system program.
allocation: When multiple system or o.1
E 3x p l a i n
These are
generally
vailable
avai as assembly language instruc
ctions,
Scanner and
Communicati
programmertheys.
in the various model.
are usually listed
can be grouped
in five different categoriec .
tion is
intormatior exchanged thru an In
interprocess communication message passing
mode
System Calls
need to be able to
ectem
operating system before before communication can take facility provided by the
1. Process
Control:- A running program
halt its network has a host connection must be opened.
in a place, a
execution
ch computer
either normally
(end) or
known. Similarly each process has a name by which it
a program
abnormally or a
problem and causee
program runs into a n terrorermintrap,ate
dentifier
an equivalent ider by which an
s common
Operating
process name, which is translated
a dump of
memory is
sometimes taken and an error message
generated. The dump into cessed System Calls do this translation.System can
refer to it. The gethostid
Most process that will be receiving
is written to a
disk and may be examined by a
debugger to determine the cause ions is special purpose ademons
abnormal circumstances, the Operati system programs provided
c o n n e c t i o
of a problem
under either normal or
The clos connection
call terminates the for that purpose.
must transfer control to the command interpreter
command interpreter. The command inte System communication.
tn shared memory model, processes use
reads the next
command. then map memory system calls to gain
to regions of memory used
by other processes. Shared
A process or job executing one program may want to load and execute memory requires that
acces
Following are
Spooling: It is
an acronym
for Simultaneous peripheral
operation 2005 jew: The process is
being created.
shown in fig.
-line. The Instructions
spooling
of is ci) Running: are
process being executed
(ii) Waiting: The process is
nletion or reception of signals. waiting for some event to occur,
Disk ur, such as an
Ready: The process
is watng to be
Terminated: The process assigned to a
processor
( has finished execution task.
Q,20 W h a t is PCB? Explain briefly. Nov
Fach process, which has been 2016,2015, Dec 13,
13 Feb 02
Card created. It is identified with the
o fi n f o r m a t i o n . The information identifies the current state help of a number
Reader CPU of the process. The required
Printer informatio red in a
is storeddata structure called
as Process Control
Block.
Fig: Spooling process The operating system uses PCB to keep track of
the status of the process.
The advantages over buffering are: Some of the information included in the PCB are:
Scheduling of process and memory is very simple. 1. Current state of the process
(Ready/Run/wait)
.It do not require any critical device management. 2. Process identification number.
It provides simple forms of file management 3. Process priority
.Little protection and no conCurrency control 4. Pointers to allocated resources
of file access is required,
5. Input-output status information
Q.18 Explain virtual machines. Nov
The basic idea behind a virtual machine
2011, Dec 2010 6. Program counter
is to obstract the
single computer containing the
hardware of a 7. Other fields
CPU, memory, harddisk, network interface
so on into many different environments. This words an cards and
illusion of each Process
executing environment running its own seperate Pointer
does not provide the additional
private computer. Further a virtual machine 6tate
features of a process such as
file system. system calls and a Process Number
Process Counter
Q.19 Define Process. OR Job and
process as related to O.S. Registers
Nov 2016, 2015, Dec
A task or
job or event being in execution
2009, June-07 Memory Limits
being in is called process. Say a
execution also called as a progrdi List of open files
process.
process is more than
as
represented by the value of theprogram code, it also includes the current actV
sers. A process generally alsoprogram counter and the contents of the
includes the process. Stack pr
rs
Process Control Block (PCB)
dla (Such as subroutine parameters containing tempo Fig:
global variables. temp varsables) and a data section Con
rangS
Neeraj's Third Semester BCA C-19
C-18 canner
Jobs waiting
Nov 2015, 2011, Dec 10,
scheduling?
Q.21 What is
preemptive
is aranting acceptable respon
guara
o09
secheduling is important
Preemptive
ctive,. The
premption effective,,
make The times. Jobs waiting
Preemption is
without cost. To
not processes must
that the next process Is ready for the CPU i for initiation
ho
be keot in main storage so
Q.22 Give the meaning non preemptive scheduling. Nov 2015, 2011. Low level scheduling
In a non preemptive scheduling, a selected job runs to completion. It means
that the running process retains ownership of the allocated resources including the Running Processes
processor, until it voluntarily surrenders control to the operating system. However
when the running process becomes suspended as a result of its own action, say
by waiting for an 1/0 completion, another ready process may be scheduled.
The decision may takesplace under the of the
Completed
one following conditions.
() When a process switches from the running state to waiting state (eg.
I/0 request)
Non-Preemptive
between preemptive and
(i) When a process terminates Describe the difference Nov 2012, Dec-2004
Q.24
Under the non-preemptive scheduling, once the CPU has been allocated scheduling algorithm.
to
a process, the process keeps the CPU until it releases the CPU either Differences are:
by terminating
or by
switching to the waiting state. Non-preemptive
Ex: This
Preemptive
scheduling method is used by Microsoft Windows Environment.
be taken away
1. The CPU can
7. If interrupt
occurs, process is 7. If interrupt occurs,
process is Interrupt Terminated
temporarily suspended terminated.
Eit
for real time, and 8. It is suitable for batch Peady
8. Its in suitable processing Punning
interactive time sharing systems
Shed ular dispatch
or event
completion
VO Wa iting VO or event wait
Q.25 Explain FCFS scheduling. Dec
2013, 2010, 2005
First-come-first-serve (FCFS) is a simplest scheduling algorithm. Here.
the CPU First, allocated the CPU first processes are the Fg: Satesof a process
process that request
according to their arrival time on the ready queue 1.e. requests are dispatched
scheduled n
the order in which they arrive the system.
The New State indicates that a passive program has just been converted
The FCFS is a nonpreemptive:Once the CPU has been allocated
to a proceee to a
dunamic activity called a process. In the RUNNING state the process possess
that process keeps the CPU until it releases the CPU, either resources required for its execution including the CPU. The running process
by terminating or
requesting 1/0. by
eCutes a sequence or instructions and may go to the WAIT state when it calls
Advantages: n the Operating System to perform on I/0 - Operation. In a normal sequence
Disadvantages: th11
() It takes long average waiting time. 0.27 Explain co-operative process. Dec 2013
(i) One CPU and many 1/0
requests at thís situation both CPU if it does affect or gets affected by
in idle state. and 1/0 are A process is said to be co-operating
shares
co-operating process, definitely
other processes executing in the system. A
(ii) Not suitable timesharing systems. contains the some of the benefits.
data with other processes. The co-operating process
(iv) Cannot guaranteed good of information
Concurrent access to some piece
response time. () Information sharing:
to server users.
be provided
shared file
Q.26 Describe the process state
help of process
Un as a can
speedup computation
of a task, the task
transation diagram. ( ) Computational speedup:
To
will be executing in parallel
Process State: As a Nov 2017
divided into subtasks so
that each them of
S defined
in part
process executes, it changes state. The
state of a process De
by the current activity of that with others.
one of the process. Each process may be in construct a modular system by dividingg
to
following states. (n) Modularity: It may
be required
threads.
or
the Ystem functions into separate processes
mechanism is required for co-operating
nter process
communication (IPC)
information.
processes to exchange data and
Short-term-scheduler. The
scheduler selects from amono
the heduling algori with an example.
0)
that are ready to
execute and allocates the CPU to
one of them. processes Dec 2010, 2005
In memory
scheduler. All the processes are spooled to a suitahia SHORTES JOB FIRST ($JF)
c) Long-term
storage Scheduling:
where they are kept
for execution at a later stage. The long-term The main conside
deration of this algorithm is
device,
the jobs from the job p00l and loads is into memory for evecexecution. scheduler ch process. wWhen the CPU is available. It
the time required for the execution
selects is assigned to the
smaller next
each
vt CPU CPU execution time. If two or more process that has
criteria. R What are processes have the
Q.29 Explain CPU scheduling scheduling same next
Dec 2013, 2005, riteria, then the CFS is used to break the tie.
explain briefly? burst
Scheduling
is Provably
The following CPU Scheduling criterla are:
Optimal, in that it gives the
average waiting time for a given set of processes.
1, CPU utilization: We want to Keep the CPu as busy as
CP
i m u m
possible. Consider the following processes arriving for execution at time 0 with the
100 percent.
utilization may range form 0 to
burst given in microseconds.
2. Through put: The number of process that are completed per time unit ength
thof the CPU
caled throughput. Process Execution Time
3. Turnaround time:The interval from me time of submission
of a procese P 5
to the time of completion is the turn around time. Turn-around time is the sum
P
of the periods spent waiting to get into memory, waiting in the ready queue.
4. Waiting time: It is the sum of periods spent
waiting in the ready P
queue. 3
5.Response time: The time from the submission of P
a request until the then the result of their
first response is produced. If the process arrived in the order P Pay Pa P,
shown in the Cantt Chart below.
execution with SJF would be
Q.30 Explain the operation of multilevel scheduling.Nov 2017,Dec-06
This scheduling has been created for situations in which processes are P3 P4 P1 P2
classified into different groups. For example, a common division easily
is made between 10 17
interactive processes and batch processes. These two
types of processes have different
response time requirements, and so might have different
scheduling needs. In Banker's algorithms. Nov 2017,2016,2012, Dec 10,09,05
addition, interactive processes
may have priority over batch processes. Q.32 Explain avoidance policy. Hence no validity constraint
uses an
Banker's algorithm: It request. The
make any kind of
resource
are free to
Highest priority 5 Specified, and processes,
test and safety
test.
feasibility
System process ystem uses 2 tests, called
feasible request if, after granting
e a s i b l e request: A request
Req,x is a
exceed the total
number
Interactive Processes total allocated
resources of class K do not
request, the
Interactive editing processes of resources of class K system.
a safe request
at time t, after
feasible request
Req J, K is of allocations
request: A one sequence
Batch processes are at least
t. There exists
he at time
request complete.
n can
is kept
Lower priority Student processees released by which all processes
at any
time. An unsafe request
safe requests
e system only grants
Multilevel Queue scheduling Pending even if it is feasible.
described,
scheduling. systems are
Q.33 Explainreal time
real time
operating
two categories.
required by divide into
Cheduling
facilities comptueris
general-purpose
C-25
Neeraj's Third Semester BCA Scan gets
a smallnall lim
limit of CPU time
p rrOcess
o c time has ela psed, the (time quantum),
C-24
nds. After t h i s
process is
usually -100
real-time
systems the ready queue. preempted (halted) and added
Hard
(i) e
(i) Soft
real-time
systems t h e
the
Consider t he following set of
processes that arríve at time 0, with the
are normally required to evee...
-Burst time given in milliseconds. lengtn
systems: Systems and t h e CPU-Burst
Hard real-time of time. If the cchad
guaranteed period
within a
ete a given task Within the specified time , can Process Burst time
be completed
arantee that the process
will admits 24
P1
the process
is allocated
the CPU first
processes
are scheduled in
their
ysems. It is
very much similar to FCFS designed especially for time-sha the ord the system.
scheduling. But premition Is addu Here in which they arrive
CA SCann
-26
Scanneer we discuSS Scheduling C-27
some fixed no's, terms
H e r e
10 Priority
P1 3
n) The implementation requires us to consider a natural data structira 1
P2
called 2
a queue. P3
(it) When the process enters the ready queue, its PCB is linked on 1
p4 4
tail of the queue.
the P5
5
2
(iv) When the CPU is free, it is allocated to the process at the head priority scheduling, we would
ready queue.
af
the
s
Gantt c h a r t :
schedule these processes according following
(v) It is very simple to understand and implement
Consider the following set of processes that arrive at time 0, with the P2 P5 P1
lenath P3 P4
of the CPU-burst time given in ms
0 1 16 18 19
Process Burst Time
The average waiting time
P1 (6+0+16+18+1)/5
P2 8.2 mi.s
P3 The average turn around time =((6+10)+(0+1)+(16+2)+(18+1)
+ (1+5))/5 = 12 mi.s
If the processes arrive in the order P1, P2, P3 and served in
a.
FCFS order Advantages:
we execute the process as given in the following Gantt Chart.
(i) Good response time
P1 P2 | P3 Cii) Support multitasking systems
12 13
(ii) Supports both preemptive and non-premptive
The waiting time is 0 ms for the process P1, 8 ms for process P2 and 13
ms for process P3.Thus,
Disadvantages:
i) Implimentation is difficult
The average waiting time is (0 + 8+ 12) / 3 6.66ms
(ii) It results in starvation
Theaverage Turnaround time is (0 + 8) + (8 4) + (12 +1) / 3= 11 a simple
ms algorithms available, usingNov 2012
9.39 Compare all the scheduling
. If the processes were
sent in the order P3, P2 and P1 then, waiting time example problem.
for process P3 is
0, P2 is 1 and for, process P1 is 5 ms. For the FCFS:
Thus, the average waiting time is Process Burst Time
(0 + 1 + 5) /3 =
2ms.
P1
Q.38 Discuss priority 24
A
priority is
scheduling.
associated
Nov 2012 P2 3
with each process and the CPU is allocated
LES the to P3 P2, P3 The Gantt
WIh
server (FCFS)
highest
order.
priority and equal priority are scheduled in first come arrive in the
order: P1,
,
Third Semester
C-28 BCAISc
Scanner P3 2
= 0; P2 = 24; P3 = 27
C-29
for P1
Waiting time
pP4 1
4
Average waiting time: (024 t+ 27)/3 =17 P5 4
2
For the SJF
The orocesses are.
assumed to have
Associate with each process the length of its next CPU burst.
Waiting time of P2
=
0 milliseconds Nonpreemptive priority: C-31
time of P1
Waiting time of P3
2 = milliseconds
Turn
aroun
=
t +5
alind time of 8+t2=
Waiting time of P4= 1 milliseconds
ind time of
P2
P3
=ti +0+1+2= (M+t2+13)milisecon
(N+2-
conds
miliseconds
= Turn around =
tl +13+2 2
Averagewaiting time = ( 8 +0+2+ 1 + 4 ) / 5 3 milliseconde
nds Ound time
Turn arouno of P4 =
ti +15+ 1 2
=
(Mt215) milliseconds
Non preemptive priority: -Ound time
Turn a r o u n d of P5 =
ti
+1+4 2
=
(ti-2+16) miliseconds
2-5 miliseconds
=
Turn +
2+1+t2
Waiting time of P4 15 milliseconds
around time of P3 tl +3
2-3milliseconds
=
i) FCFS:
more than two.
Turn around time of P1 =
t1 + 0 + 8 + t2
Turn around time of
=(ti +t2 +8) milliseconds Algorithm: integer
P2 =
ti + 8 1 + t2 boolean array; and
turn is an
Turn around time of
=
(t1 +t2 +9) milliseconds aglis
P3 =
t1 + 9+ 2+ t2
Turn around time
=
(t1+ t2 + 11)millisecondS flag[0] = false;
of P4 =
t1 +11 + 1+ t2
Turn around time of P5
=
(t1+ t2 + 12)milliseconas flagi1] = false;
=
t1 + 12 + 4 +
SJF: t2 ( t1+ t2 + 16)millseconaa
=
turn;
PO: flag[O] =
true
urn around time of P1 =
t1 + 8+ 8+ t2
urn around time of P2
=(t1 t t2 + 16) millsecong turn 1; tun
zs 1)
Turn
=t1 + 0 + 1+ t2 =
(t1+ t2 +1)milliseconaa While (flag[1) == true &
around time of P3=
t1 + 2 + 2+ t2
urn around time of P4
=
( t1 t t2 + 4) milise
=t1 +1 +1 + t2 =
(t1+ t2 t2) millseco /busy wait
Turnaround time of P5 =
t1 + 4+ 4 + t2 =
(ti t t2 +8) mills
I/ critical section
section
end of critical
Neeraj's Third Semester
BCA
Scanner
SYNCHORONIZATION
C-32
R O C E S S
flag[0] false;
PI: flag[1]
=
true;
NDDEADLOCKS
turn= 0; Unit 2
while (flag[0]
== true && turn
==
0)
{
/busy wait
SECTIONA
hat is process synchronization?
//critical section ten
People ofter rely on
synchronization to fix a
meeting with others. They need
D agr
atime for the meeting, the
date and the venue. By reaching an agreement
end of critical section
eing to
explicitly agreein synchronization is called as process of
// they
are
synchronization.
flag[1] = false;
semaphores? Nov 2015, 2012, Dec 2009
0.2 What is
ASemaphore is a process synchronization tool, that represents data-structures
kernel to synchronize the processes. They are particularly
IGed by operating system
the access of different accesses different to shared resources
sefull in synchoronizing
semaphore enforces mutual exclusion and
mutually exclusive manner. i.e. a
in a
controls access to the process critical section.
such that
Po is waiting
state. waiting
processes
Ge that is
Po 1 is waiting forr a r e s o u r c e
software
A monl
Ontor ls a
data.
Cizatlon code and loca