0% found this document useful (0 votes)
36 views40 pages

PDF Operating System Mcqs Gate - Compress

The document contains a series of questions and solutions related to Operating Systems, specifically focusing on concepts like virtual memory, scheduling algorithms, page replacement policies, and synchronization using semaphores. Each question is followed by a detailed explanation of the correct answer, providing insights into the underlying principles of operating systems. The content spans multiple years, indicating a collection of exam questions from GATE CS from 2001 to 2003.

Uploaded by

Selva Selvam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views40 pages

PDF Operating System Mcqs Gate - Compress

The document contains a series of questions and solutions related to Operating Systems, specifically focusing on concepts like virtual memory, scheduling algorithms, page replacement policies, and synchronization using semaphores. Each question is followed by a detailed explanation of the correct answer, providing insights into the underlying principles of operating systems. The content spans multiple years, indicating a collection of exam questions from GATE CS from 2001 to 2003.

Uploaded by

Selva Selvam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link].

com

GATE CS Topic wise Questions


Operating System

YEAR 2001

Question. 1

Which of the following statements is false ?


(A) Virtual memory implements the translation of o f a program’s
address space into physical memory address space.
(B) Virtual memory allows each program to exceed the size of the
primary memory.
(C) Virtual memory increases the degree of multi-programming
(D) Virtual memory reduces the context switching overhead.
overhead.

SOLUTION

Virtual memory enables a program to exceed the size of primary


memory so it increases degree of multi-programming.
Since data required by executing program is available here so context
switching is reduced.
But virtual memory doesn’t translate program’s address space into
physical memory.
Hence (A) is correct option.

Question. 2

Consider a set of n task


taskss wit
with
h kno
known
wn run
runtim
times
es r1, r2, ...
......
.....
..rn to be
run on a uniprocessor machine. Which of the following processor

scheduling algorithms will result in the maximum throughput ?


(A) Round-Robin (B) Shortest-Job-First
CS Topicwise 2001-2010
Operating System [Link]

(C) Highest-Response-Ratio-Next (D) First-come-First-Served

SOLUTION

Here the running times r1 ....rn are already known, single processor
system. In this scenario, throughput i.e. CPU is maximum utilized in
shortest job first scheduling.
Hence (B) is correct option.

Question. 3

Where does the swap space reside ?


(A) RAM (B) Disk
(C) ROM (D) On-chip cache

SOLUTION

Swap space is the memory space where the part of the program not
currently in main memory for execution is stored, this program part
can be swapped into memory when required.
This space is generally in disk.
Hence (B) is correct option.

Question. 4

Consider a virtual memory system with FIFO page replacement


policy. For an arbitrary page access pattern, increasing the number
of page frames in main memory will.

(A) Always decrease the number of page faults


(B) Always increase the number of page faults
(C) Sometimes increase the number of page faults
(D) Never affect the number of page faults

SOLUTION

During F1F0 page replacement policy, due to increase in the no. of


page frames in memory should decrease the no. of page faults since
more frames can be kept there.
But due to Belady’s Anomaly after certain limit or in some page
access instances no. of page faults are high.
Hence (C) is correct option.
Page 2
CS Topicwise 2001-2010
[Link] Operating System

Question. 5

Consider a machine with 64 MB physical memory and a 32-bit virtual


address space. If the page size is 4 KB, what is the approximate size
of the page table ?
(A) 16 MB (B) 8 MB
(C) 2 MB (D) 24 MB

SOLUTION

Size of main memory 64 MB


=
32
Size of virtual memory = 2 B
32
No. of pages = 212
2
= 220 pages
Required 1 M enteries.
But each entry has both a virtual address & corresponding physical
address.
Total bits in each entry = 32 + 26 (Physical)
= 58

=
58 = 8 Bytes.
8

So total memory = 8 # 1 MB
= 8 MB
Hence (B) is correct option.

Question. 6

Consider Peterson’s algorithm for mutual exclusion between two


concurrent processes i and j . The program executed by process is
shown below.
repeat
flag[
ag[i]=
i]=tru
true;
e;
turn=j;
while(p)do no-op;
Enter critical section, perform actions, then
exit critical section
Flag[i]=false;
Perform other non-critical section actions.

Until false;
For the program to guarantee mutual exclusion, the predicate P in
Page 3
CS Topicwise 2001-2010
Operating System [Link]

the while loop should be


(A) flag [j]= true and turn =j (B) flag [j]=true and turn =j
(C) flag [i]=true and turn=j (D) flag [i]=true and turn=i

SOLUTION

While loop if true predicate then the program enters into critical
region. This program enters into critical region of flag [i]=true act
as semaphore, & true =j, the requirement of resource is by some
other process.
Hence (B) is correct option.

YEAR 2002

Question. 7

Which of the following scheduling algorithms is non-preemptive ?


(A) Round Robin
(B) First-In First-Out
(C) Multilevel Queue Scheduling
(D) Multilevel Queue Scheduling with Feedback

SOLUTION

Round robin is preemptive since processes are cycled for CPU time,
& run for a particular time stamp in one cycle. Multilevel queue
scheduling maintains various quenes, each having different priorities.
But in FIFO scheme, only the process which enters once, would be
completed first, so no. preemption.
Hence (B) is correct option.

Question. 8

The optimal page replacement algorithm will select the page that
(A) Has not been used for the longest time in the past.
(B) Will not be used for the longest time in the future.

(C) Has been used least number of times.


(D) Has been used most number of times
Page 4
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

Optimal page replacement algorithm assumes that the pages that


will come in future are already known, so replacement of the page
which will not be used in future occurs.

Hence (B) is correct option.

Question. 9

Which combination of the following features will suffice to characterize


an OS as a multi-programmed OS ? More than one program may be
loaded into main memory at the same time for execution. (B) If
a program waits for certain events such as I/O, another program
is immediately scheduled for execution. (C) If the execution of a
program terminates, another program is immediately scheduled for
execution.
(A) A (B) A and B
(C) A and C (D) A, B and C

SOLUTION

Multi-programmed:- More than one program can run on single CPU,


when one is blocked.
(A) Is true and a characteristic of multi-programmed
(B) Is true & also characterise a multi-programmed OS
(C) Is true but no necessary for this type
type this happens in all OS, even
in batch processor.
Hence (B) is correct option.

Question. 10

In the index allocation scheme of blocks to a file, the maximum


possible size of the file depends on
(A) The size of the blocks, and the size of the address of the blocks
(B) The number of blocks used for the index, and the size of the
blocks.
(C) The size of the blocks, the number of blocks used for the index,

and the size of the address of the blocks.


(D) None of the above.
Page 5
CS Topicwise 2001-2010
Operating System [Link]

SOLUTION

When indexes are created, the maximum no. of blocks given to a file
are totally dependent upon size of the index which tells how many
blocks can be there, & size of each block.
Hence (B) is correct option.

YEAR 2003

Question. 11

Using a larger block size in a fixed block size file system leads to
(A) better disk throughput but poorer disk space utilization
(B) better disk throughput and better disk space utilization
(C) poorer disk throughput but better disk space utilization
(D) poorer disk throughput and poorer disk space utilization

SOLUTION

Using larger block size in a fixed block size system lead to poor disk
space utilization due to data items which are very small comparable
to block size cause fragmentation. But it leads to better
b etter disk through
put since no. of blocks needs to fetch & replace become less.
Hence (A) is correct option.

Question. 12

In a system with 32 bit virtual addresses and 1 KB page size, use of

one-level
practical page tables
because of for virtual to physical address translation is not
(A) the large amount of internal fragmentation
(B) the large amount of external fragmentation
(C) the large memory overhead in maintaining page tables
(D) the large computation overhead in the translation process

SOLUTION

32 bit virtual address, i.e. 2 32 kB of virtual memory & 1 kB page size.


So total pages = 232 .
So. we need to maintain a page table of 232 rows, this require 4
GB main memory which is quite impractical due to large memory
Page 6
CS Topicwise 2001-2010
[Link] Operating System

overhead.
Hence (C) is correct option.

Question. 13

A uni-processor
which alternate 10computer
ms CPUsystem
bursts only hasms
with 90 two processes,
I/O boththe
bursts. Both of
processes were created at nearly the same time. The I/O of both
processes can proceed in parallel. Which of the following scheduling
strategies will result in the least CPU utilizations (over a long period
of time) for this system ?
(A) First come first served scheduling
(B) Shortest remaining time first scheduling
(C) Static priority scheduling with different priorities for the two
processes
(D) Round robin scheduling with a time quantum of 5 ms .

SOLUTION

There should be no doubt that round robin scheduling would lead to


maximum CPU utilization, but since in FCFS one task would starve
for a long time so min CPU utilization would be in this case.
Hence (A) is correct option.

Data for Q. 14 & 15 are given below.

A processor uses 2-level page table fro virtual to physical address


translation. Page table for both
b oth levels are stored in the main memory.
memory.
Virtual and physical addresses are both 32 bits wide. The memory is
byte addressable. For virtual to physical address translation, the 10
most significant bits of the virtual address are used as index into the
first level page table while the next 10 bits are used as index into the
second level page table. The 12 least significant bits of the virtual
address are used as offset within the page. Assume that the page
table entries in both
b oth levels of page tables are 4 a bytes wide. Further,
Further,
the processor has a translation look aside buffer(TLB), with a hit
rate of 96%. The TLB caches recently used virtual page numbers and
the corresponding physical page numbers. The processor also has a
physically addressed cache with a bit ratio of 90%. Main memory
access time is 10 ns , cache access time is 1 ns , and {LB access time
Page 7
CS Topicwise 2001-2010
Operating System [Link]

is also 1ns .

Question. 14

Assuming that no page faults occur,


o ccur, the average time taken to access
a virtual address is approximately (to the nearest 0.5 ns )
(A) 1.5 ns (B) 2 ns
(C) 3 ns (D) 4 ns

SOLUTION

TLB is successfully 96% of total request & for remaining 4%. RAM
is accessed twice.
So average time taken.
= .96 (1 + (0.9 # 1) + 0.1 # (1 + 10))
+ ..0
04 (21 + (.9 # .1)) + 0.1 # (1 + 10)
= .96 (1 + .9 + 1.1) + 0.4 (21 + .09 + 1.1)
= .96 # 3 + 0.4 # 23
= 2.88 + .92
= 3.80 , 4 ns (Nearest .5)
Hence (D) is correct option.

Question. 15

Suppose a process has only the following pages in its virtual address
space; two contiguous code pages starting at virtual address
0 # 0000000, two contiguous data pages starting at virtual address
0 # 00400000,and a stack page starting at virtual address
0 # FFFFF000. The amount of memory required for storing the page
tables of this process is
(A) 8 KB (B) 12 KB
(C) 16 KB (D) 20 KB

SOLUTION

Total no. of pages required = 5


But due to 2 level page table = 2 # 4 kB # 2
= 16 kB
Hence (D) is correct option.

Data for Q. 16 & 17 are given below.


Page 8
CS Topicwise 2001-2010
[Link] Operating System

Suppose we want to synchronize two concurrent processes P and Q


using binary semaphores S and T. The code for the processes P and
Q is shown below.
Process P Process Q:
while(1) { while(1) {
W: Y:
print ‘0’; print ‘1’
print ‘0’; print ‘1’
X: Z:
} }

Synchronization statements can be inserted only at points W,X,Y


and Z.

Question. 16

Which of the following will always lead to an output staring with


‘001100110011’?
(A) P(S) at
a t W, V(S) at X, P(T) at Y, V(T) at Z, S and T inutuakkt
1
(B) P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S initially 1, and
T initially 0
(C) P(S)
P(S ) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1
(D) P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S initially 1, and
T initially 0

SOLUTION

For output string 001100110011 alternatingly we require process P &


Q to execute.
For this to happen
happ en P(s) with S = 1 should be placed at W.
At the same time P(T) with T = 0 will be at Y.
At X we have
have V (T) which will have
have T = 1 so process Q starts.
At the sasame
me ti
time
me at
at Z we
we hav
have V(s)
V(s) whi
which
ch ma
makke S = 0 to stop
process P.
Hence (B) is correct option.

Question. 17
Which of the following will ensure that the output string never
Page 9
CS Topicwise 2001-2010
Operating System [Link]

contains a substring of the form 0.1” or 10”1 where n is odd?


(A) P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1
(B) P(S)
P( S) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1
(C) P(S) at W, V(S) at X, P(T) at Y, V(S) at Z, S initially 1

(D) (S) at W, V(T) at X, P(T) at Y, P(S) at Z, S and T initially 1

SOLUTION

To ensure this
this condition substringg of form 01n 0 oorr 10n 1, where n
condition that substrin
is odd S should be initially 1, we will case only 1 semaphore S.
So at W P (s), at X V (s)
Whereas at Y P (s)
(s),, at Z V (s)
Hence (C) is correct option.

YEAR 2004

Question. 18

Consider the following statements with respect to user-level threads


and kernel-supported threads
(i) Context which is faster with kernel-supported threads
(ii) For
For user-level threads. a system call can block the entire
e ntire process
(iii) Kernel-supported threads can be scheduled independently
(iv) User-level threads are transparent to the kernel
Which of the above statements are true?
(A) (ii),(iii) and (iv) only (B) (ii) and (iii) only
(C) (i) and (iii) only (D) (i) and (ii) only

SOLUTION

(I) It is false, context switch is not faster in support of kernel


threads.
(II) A system call can truly block the user level threads, since they
don’t have permission to do that.
(III) True since kernel supported threads have their independent
memory & resources.
(IV) False since user level threads might need support of kernel
threads.
Page 10
CS Topicwise 2001-2010
[Link] Operating System

Hence (B) is correct option.

Question. 19

Consider an operating system capable of loading and executing a

single sequential
algorithm user Come
used is First process at aServed
First time.(FCFS).
The disk head scheduling
If FCFS is replaced
by shortest seek Time Fist (SSTF), claimed by the vendor to given
50% better beachmark results, what is the expected improvement in
the I/O performance of user programs?
(A) 50% (B) 40%
(C) 25% (D) 0%

SOLUTION

I/O performance is not entirely dependent upon disk access, it has

effect
reduceofdisk
various other
access t imedevices,
time but no so using SSTFininthe
improvement place of FCFS may
I/O is done.
Hence (D) is correct option.

Question. 20

The minimum number of page frames that must be allocated to a


running process in a virtual memory environment is determined by
(A) the instruction set architecture
(B) page size
(C) physical memory size

(D) number of processes in memory

SOLUTION

Page frames are allocated


allocate d in main memory,
memory, for virtual memory pages.
This no. of page frames depends upon
up on the instruction set architecture.
Hence (A) is correct option.

Question. 21

Consider the following set of processes, with the arrival times and the
CPU-burst times given in milliseconds
Proc
oceess Arrival ti
time Burst ti
time
Page 11
CS Topicwise 2001-2010
Operating System [Link]

P1 0 5
P2 1 3
P3 2 3
P4 4 1

What is the average turnaround time for these processes with


the preemptive shortest remaining processing time first (SRPT)
algorithm?
(A) 5.50 (B) 5.75
(C) 6.00 (D) 6.25

SOLUTION

Then ar
Then arou
ound
nd ti
time
me = (S
(Sub
ubmi
mitt ti
time
me − fi
fini
nish
sh ti
time
me))
Gantt chart for the scheduler.

T.A time for P1 = 12 − 0 = 12


12
P2 = 4−1 = 3

P3 = 8−2 = 6

P4 = 5−4 = 1

Total = 22

Avg turn around time =


22
4

= 5.5
Hence (A) is correct option.

Question. 22

Consider a system with a two-level paging scheme in which a regular


memory access takes 150 nanoseconds, and servicing a page fault
takes 8 milliseconds. An average instruction takes 100 nanoseconds
of CPU time, and two memory accesses. The TLB hit ratio is 99%,
and the page fault rate is one in every 10,000 instructions. What is
the effective average instruction execution time?

(A) 645 nanoseconds (B) 1050 nanoseconds


(C) 1215 nanoseconds (D) 1230 nanoseconds
Page 12
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

Memory access time


=.90 # 150 + .10 # (150 + 150)
=1
1335 + 30
=
1651 ns −4
The error rate = = 10
10000

CPU burst time = 100 ns


Total execution time
−4 6
= [100 + 2 [165] + 10 # 8 # 10 ]
= 100 + 330 + 800
= 100 + 1130
= 1230 ns
Hence (D) is correct option.

Question. 23
Consider two processes P1 and P2 accessing the shared variables X
and Y protected by two binary semaphores Sx and Sy respectively,
both initialized to 1. P and V denote the usual semaphore operators,
where P decrements the semaphore value, and V increments the
semaphore value. The pseudo-code of P1 and P2 is as follows:
P1: :
while true do{ while true do{
:......  :......
:..... :.......
     
       
 
  

 
 }  
  }

In ord
order
er to av
avoid
oid dea
deadloc
dlock,k, the cor
correc
rectt opera
operator
torss at L1, L2, L3 and L4
are respectively
(A) P (SY ), P (SX ); P (SX ), P (SY ) (B) P (SX ), P (SY); P (SY ), P (SX )
(C) P (SX ), P (SX ); P (SY ), P (SY ) (D) P (SX ), P (SY ); P (SX ), P (SY )

SOLUTION

Here semaphores are required to obtain mutual exclusion since both


Page 13
CS Topicwise 2001-2010
Operating System [Link]

access X & Y . So at L1 P (Sx ) which means now Sx = wait at L2 P (Sy)


Sy wait, this prevents process P2 to start access X &Y .
V (Sx ) & V (Sy) in the end of P1 makes Sx & Sy signal so that at L3 &
L 4 P (Sx ) & P (Sy) can start.
Hence (D) is correct option.

Question. 24

A Unix-style I-node has 10 direct pointers and one single, one double
and one triple indirect pointers.
p ointers. Disk block size is 1 Kbyte, disk block
address is 32 bits, and 48-bit integers are used.
used . What is the maximum
possible file size?
(A) 224 bytes (B) 232 bytes
(C) 234 bytes (D) 2 48 bytes

SOLUTION

Size of 1 block = 1 kB
Block addresses size 1 pointer size = 32 bit
= 4 bytes.
10
So no. of pointers in = 2 2 B
2B
1 block = 256
So direct pointer will have = 10 # 1kB = 10kB
Double will have = 256 # 256 # 1 kB
Triple will have = 256 # 256 # 256 # 1 kB
8 8 8 10
= 2 #2 #2 #2 B
34
= 2 B
Hence (C) is correct option.

YEAR 2005

Question. 25

Suppose n processes, P1,..... Pn share m identical resource units, which


can be reserved and released one at a time. The maximum resource
requirement of process Pi is sp where si < 0. Which one of the following
is a sufficient condition for ensuring that deadlock does not occur?
(A) 6i, s < m (B) 6i, s, < n
n n
(C) /si < (m + n) (D) / si < (m * n)
i=1 i=1
Page 14
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

For every Pi Si is maximum resource requirement where Si > 0 .


To allot resources to all processes without any deadlock situation is
n
/ Si < (m + n)
i=1

i.e. sum of all maximum resource requirement should be less than


m + n.
Hence (C) is correct option.

Question. 26

Consider the following code fragment:


if (fork()==0
{a = a + 5; print f ("%d,%
, %/ n"a, and a);}
else {a − 5; print f ("%d,%
,% d/n",
" , a,& a);}
let u , vbe the values
values printed by
by the parent
parent process, and x, y be the
values printed by the child process. Which one of the following is
TRUE?
(A) u = x + 10 and v = y (B) u = x + 10 and v ! y
(C) u + 10= x and v = y (D) u + 10 = x and v ! y

SOLUTION

Initial value of a is let 10 and its address & a would be different for
both parent & child process so.
(A) & (B) are incorrect also parent process executes a = a − 5 = 5 = u
& child executes a = a + 5 = 15 = x so u + 10 = x
Hence (D) is correct option.

YEAR 2006

Question. 27

Consider three CPU-intensive processes, which require 10,20 and 30


time units and arrive at times 0,2, and 6, respectively. How many
context switches are needed if the operating system implements a
shortes remaining time first scheduling algorithm? Do not count the
context switches at time zero and at the end
(A) 1 (B) 2
Page 15
CS Topicwise 2001-2010
Operating System [Link]

(C) 3 (D) 4

SOLUTION

When CPU burst are given to another process, called context


switching. The Gantt chart for shortest remaining time first is.

So there are two context & witches at T = 10 & T = 30


Hence (B) is correct option.

Question. 28

The atomic
memory feth-and-set
location x, yfetches
x to 1 and instruction
the oldunconditionally
value of x in y sets the
without
allowing any intervening access to the memory location x . Consider
the following implementation of P and V functions on a binary
semaphore S.

void p (binary_semaphore*S){
unsigned y;
unsigned*x =& (S->value);}
do {
fetch-and-set x,y;

} while(y);
}
void V (binary_semphore*S){
{S_>value = 0;
}
Which one of the following is true?
(A) The implementation may not work if context switching is disabled
in P
(B) Instead of using fetch-and-set, a pair of normal load/store can
be used

(C) The implementation of V is wrong


(D) The code does not implement a binary semaphore
Page 16
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

If there are more than two processes and context & switching processes
is disabled in P then this implementation doesn’t work properly and
can’t synchronize the processes.

Hence (A) is correct option.

Question. 29

A CPU generates 32-bit virtual addresses. The page size is 4 KB. The
processor has a translation look-aside buffer (TLB) which can hold a
total of 128 page table entries and is 4-way set associative.
The minimum size of the TLB tag is
(A) 11 bits (B) 13 bits
(C) 15 bits (D) 20 bits

SOLUTION

TLB has 128 page table enteries, each page table would have. 64 bits
i.e. 32 + 32 virtual addresses.
So total memory required.
27 # 26
But 4 way set associative.
27 # 26 = 211
22

So 11 bits are required.

Hence (A) is correct option.

Question. 30

A computer system supports 32-bit virtual addresses as well as 32-bit


physical addresses, Since the virtual address space is of the same size
as the physical address space, the operating system designers decide
to get rid of the virtual entirely.
entirely. Which one of the following is true?
(A) Efficient implementation of multi-user support is no longer
possible
(B) The processor cache organization can be made more efficient now

(C) Hardware support for memory management is no longer needed


(D) CPU scheduling can be made more efficient now
Page 17
CS Topicwise 2001-2010
Operating System [Link]

SOLUTION

Since both virtual and physical memory has 32 bit addresses, so there
is no need for address translation hardware is required.
Hence (C) is correct option.

Question. 31

Consider three processes (process id 0,1,2, respectively) with compute


time bursts 2,4, and 8 time units. All processes arrive at time zero.
Consider the longest remaining time first (LRTF) scheduling
algorithm. In LRTF ties are broken by giving priority to the process
with the lowest process id . The average turn around time is
(A) 13 units (B) 14 units
(C) 15 units (D) 16 units

SOLUTION

Process id 0 1 2
CPU burst 2 4 8
So we draw Gantt chart for scheduler

At t = 0 longest remaining time for P2


At t = 4 remaining times for both P1 & P2 is 4 so P1 is given priority.
At t = 8 remaining time for P0 P1 & P2 is 2 P0 is given priority &
=
cyclically done till t T 14
Process A .T
P0 1122 − 0 = 12
P1 13 − 0 = 13
P2 14 − 0 = 14 = 13 units.
39
3
Hence (A) is correct option.

Question. 32

Consider three processes, all arriving at time zero, with total


execution time of 10, 20 and 30 units, respectively. Each process
spends the first 20% of execution time doing I/O, the next 70% of
time doing computation, and the last 10% of time doing I/O again.
Page 18
CS Topicwise 2001-2010
[Link] Operating System

The operating system uses a shortest remaining compute time first


scheduling algorithm and schedules a new process either when the
running process get blocked on I/O or when the running process
finishes its compute burst. Assume that all I/O operations can be
overlapped as much as possible. For
For what percentage of time does the
CPU remain idle?
(A) 0% (B) 10.6%
(C) 30.0% (D) 89.4%

SOLUTION

Proc
oces
esss First I/0 Com
ompu
puta
tati
tion
on Se
Seco
cond
nd I/0 Total
2 7 1 10
2 4 14 2 20
3 6 21 3 30
Since I/0 can be done parallely.
Gantt chart

Total time taken = 51 units


CPU has to wait = 6 units
6 100
51 #
=

= 10.6%
Hence (B) is correct option.

Question. 33

Consider the following snapshot of a system running n processes.


Process i is holding xi instances of a resource R , for 1 # i # n .
Currently,, all instances of R are occupied. Further, for all i , process
Currently
Page 19
CS Topicwise 2001-2010
Operating System [Link]

i has placed a request for an additional y , instances while holding the


xi instances it already has, There are exactly two processes p and q
such that yp = yq = 0 : Which one of the following can serve as a
necessary condition to guarantee that the system is not approaching
a deadlock?
(A) min(xp, xq) < maxk ! p, q yk (B) xp + xq # maxk ! p'q yk
(C) min(xp, xq) < 1 (D) min (xp, xq) > 1

SOLUTION

Here option (B) is that


min (X p, Xq) < max k =Y p, q yk
Means the min no. of resources allocated should be less than the
maximum no. of resources required by any process other than p & q
.It prevent from deadlock.
Hence (B) is correct option.

Data for Q. 34 & 35 are given below.


Barrier is a synchronization construct where a set of processes
synchronizes globally i.e. each process in the set arrives at the barrier
and waits for all others to arrive and then all processes leave the
barrier. Let the number of processes in the set be three and S be a
binary semaphore with the usual P and V functions. Consider the
following C implementation of a barrier with line numbers shown on
the left.

Void barrier(void) {
1 : P(S)
2 : Process_arrived++;
3 : V (S) :
4 : while (process_arrived’=3);
5 : P(S);
6 : Precess_left++;
7 : if(process_left==3)
8 : process_arrived=0;
9 : process_left+0;
10 : }
11 : V(S);
}

Page 20
CS Topicwise 2001-2010
[Link] Operating System

The variable process_arrived and process_left are shared among


all processes and are initialized to zero. In a concurrent program
all the three processes call the barrier function when they need to
synchronize globally.

Question. 34

The above implementation of barrier is incorrect. Which one of the


following is true?
(A) The barrier implementation is wrong due to the use of binary
semaphore S
(B) The barrier implementation may lead to a deadlock if two barrier
invocations are used in immediate succession
(C) Lines 6 to 10 need not be inside a critical section
(D) The barrier implementation is correct if there are only two
processes instead of three

SOLUTION

This barrier implementation is to keep track of arrival & completion


of processes in system, by incrementing no. of process arrived & left.
This implementation may lead to deadlock if two barrier function’s
invocations are used is immediate sessions.
Since V (s) in first invocation at line 3 removes 1-3 from critical section
Sin
bring 5-11 in critical section at line 7.

Hence (B) is correct option.

Question. 35

Which one of the following rectifies the problem in the implementation?


(A) lines 6 to 10 are simply replaced by process_arrived
(B) At the beginning of the barrier the first process to enter the barrier
waits until process_arrived becomes zero before proceeding to
execute P(S)
(C) Context switch is disabled at the beginning of the barrier and

re-enabled at the end.


(D) The variable process_left is made private instead of shared
Page 21
CS Topicwise 2001-2010
Operating System [Link]

SOLUTION

To rectify the barrier function at the beginning of the functions the


first process which inters the function waits until process arrived
becomes zero before executing P (s).

This
Henceremoves any deadlock
(B) is correct [Link].

YEAR 2007

Question. 36

Group-1 contains some CPU scheduling algorithms and group-2


contains some applications. Match entries in Group-1 entries in
Group-2
Group-1 Group-2

P. Gang Scheduling 1. Guaranteed Scheduling


Q. Rate Monotonic Scheduling 2. Real-time Scheduling
R. Fair Share scheduling 3. Thread Scheduling

(A) P-3;Q-2;R-1 (B) P-1;Q-2;R-3


(C) P-2;Q-3;R-1 (D) P-1;Q-3;R-2

SOLUTION

Rate monotonic scheduling is for real time processes, Gang scheduling


is used to schedule group of program threads
t hreads and fair share scheduling
is a scheduling which guarantees a fair share of CPU burst to every
competing process.
Hence (A) is correct option.

Question. 37

Consider the following statements about user level threads and kernel
level threads. Which one of the following statements is FALSE?
(A) Context switch time is longer for kernel level threads than for
user level threads
(B) User level threads do not need any hardware support
(C) Related kernal level thread can be scheduled on different
processors in a multiprocessor system
Page 22
CS Topicwise 2001-2010
[Link] Operating System

(D) Blocking one kernel level thread blocks all related threads

SOLUTION

Threading a method of executing small sub processes instead of


single big process. This prevents thread from blocking. So blocking
blo cking of
one kernel level thread doesn’t block other related threads, they are
unaffected.
So (D) is false.
Hence (D) is correct option.

Question. 38

An operating system uses Shortest Remaining Time first (SRT) process


scheduling algorithm. Consider the arrival times and execution times
for the following processes

Process Execution time Arrival time


P1 20 0
P2 25 15
P3 10 30
P4 15 45
What is the total waiting time for process P2?
(A) 5 (B) 15
(C) 40 (D) 55

SOLUTION

Gantt chart for the processes.

P2 came at t = 15
Scheduled first time at t = 20 wait = 5 .
Wait between t = 30 & t = 40 due to short remaining time of new
process P3 .
Wait now = 5 + 10 = 15
Then complete at t = 55
Page 23
CS Topicwise 2001-2010
Operating System [Link]

Hence (B) is correct option.

Question. 39

A virtual memory system uses first In First Out (FIFO) page

replacement policy
process. Consider theand allocates
following a fixed number of frames to a
statements:
P: Increasing the number of page frames allocated to a process
sometimes increases the page fault rate.
Q: Some program do not exhibit locality of reference.
Which one of the following is TRUE?
(A) Both P and Q are ture, and Q is the reason for P
(B) Both P and Q are true, but Q is not the reason for P
(C) P is false, but Q is true
(D) Both P and Q are false

SOLUTION

Dueto Belady’s Anomaly, increasing the number of page frames


allocated to a process sometimes increase the page fault rate so P is
true.
Also some program do not exhibit locality of reference, so both are
true but Q is not reason for P .
Hence (B) is correct option.

Question. 40

A single processor system has three resource types X, Y, and Z, which


are shared by three processes. There are
a re 5 units of each resource type.
Consider the following scenario, where the column alloc denotes the
number of units of each resource type allocated to each process, and
the column request denotes the number of units of each resource type
requested by a process in order to complete execution. Which of these
processes will finish LAST?
alloc request
XYZ XYZ
P0 121 103
P1 201 012
P2 221 120
Page 24
CS Topicwise 2001-2010
[Link] Operating System

(A) P0
(B) P1
(C) P2
(D) None of the above, since the system is in a deadlock

SOLUTION

Initially.
Process Allow Request/need Available
XYZ XYZ XYZ
P0 121 103 012
P1 121 012
P2 221 120

Here looking at avail


available
able resources, only need of P1 can be completed.
So P1 will execute & free 2 0 1 so now avail
available
able XYZ = 203 .
This is need for P0 so at second no. P0 will execute & free XYZ = 121
so available 3 2 4 & in the end need of P2 is fulfilled.
Hence (C) is correct option.

Question. 41

Two processes, P1 and P2, need to access a critical section of


code. Consider the following synchronization construct used by the
processes:
/* P1 */ /*P2*/
while (true) { while (true) {
wants1=true; wants2 = true;
while(wants2==true); while (wants1 == true);
/* Critical /* Critical
Section*/ Section*/
wants 1 = false; wants 2 = false;
} }
/* Remainder section*/ /*Remainder section*/

Here, wants 1 and wants 2 are shared variables, Which are initialized
to false. Which one of the following statements is TRUE about the
Page 25
CS Topicwise 2001-2010
Operating System [Link]

above construct?
(A) It does not ensure mutual exclusion.
(B) It does not ensure bounded waiting.
(C) It requires that processes enter the critical section in strict
alternation.
(D) It does not prevent deadlocks, but ensures mutual exclusion

SOLUTION

If P1 make wants 1 = true then P2 goes in critical section & vice


versa so both together
togethe r are implementing mutual exclusion but. Since
both are accessing wants 1 & wants 2 concurrently 4 wants 1 is first
captured by P1 so P2 will wait & P2 captures want 2 so P1 will have
to wait.
So a definite deadlock.
Hence (D) is correct option.

Data for Q. 42 & 43 are given below.

A process has been allocated


allo cated 3 page frames. Assume that none of the
pages of the process are available in the memory initially.
initially. The process
proc ess
makes the following sequence of page references (reference string):
1,2,1,3,7,4,5,6,3,1.

Question. 42

If optimal page replacement policy is used, how many page faults


occur for the above reference string?
(A) 7 (B) 8
(C) 9 (D) 10

SOLUTION

Reference string 1, 2, 1, 3, 7, 4, 5, 6, 3, 1
Using optimal replacement policy, we will replace that page in memory
which either will not be used or latest used in future.
Page 26
CS Topicwise 2001-2010
[Link] Operating System

) denotes page fault


So no. of page faults are 7.
Hence (A) is correct option.

Question. 43

Least Recently Used (LRU) page replacement policy is a practical


approximation to optimal page replacement. For
For the above
ab ove reference
string, how many more page faults occur with LRU than with the
optimal page replacement policy?
(A) 0 (B) 1
(C) 2 (D) 3

SOLUTION

Instead of optimal policy if we use LRU then we don’t have future


knowledge but we replace that page in memory which has been
recently used in past.
Order " 1, 2, 1, 3, 7, 4, 5, 6, 3, 1

) denotes page faults.


In this case no. of page fault = 9
In optimal strategy = 7

Difference = 9−7 = 2
Hence (C) is correct option.
Page 27
CS Topicwise 2001-2010
Operating System [Link]

YEAR 2008

Question. 44

Which of the following system calls results in the sending of SYN


packets?
(A) socket (B) bind
(C) listen (D) connect

SOLUTION

SYN packets are used for synchronization between


b etween sender & receiver,
these packets are sent by sender during connect system call for
synchronous connection.
Hence (D) is correct option.

Question. 45

The data block of a very large file in the Unix file system are allocated
allo cated
using
(A) Contiguous allocation
(B) Linked allocation
(C) indexed allocation
(D) an extension of indexed allocation

SOLUTION

Generally a large file system for UNIX OS use indexed allocation,


but for very large systems an extension of indexed allocation i.e. ext
2, ext 3 are used.
Hence (D) is correct option.

Question. 46

The P and V operations on counting semaphores, where s is a counting


ewmaphore, are defined as follows:
P (s); s = s − 1;
ifs < 0 then wait;

V (s): s = s + 1;
ifs <= 0 then wakeup a process waiting on s ;
Page 28
CS Topicwise 2001-2010
[Link] Operating System

Assume that Pb and Vb the wait and signal operations on binary


semaphores are provided. Two binary semaphores Xb and Yb are used
to impl
implemen
ementt the semaph
semaphore
ore operation
operationss P (s) and V (s) as follows:
P( s) : Pb ( Xb) ;
  
if    
  
 
}
else   
 s
s   
s  s
if s   
 
  
The initial values of xb and yb are respectively
(A) 0 and 0 (B) 0 and 1
(C) 1 and 0 (D) 1 and 1

SOLUTION

Xb & Yb are binary semaphores used to implement mutual exclusion


here. So when Xb is 1 Yb should be zero so only 1 code between the
two could run.
Since Pb (Xb) module implementing wait process so Xb should be 1.
Pb (Yb) implementing signal S = S + 1
So Yb should be
b e 0 initially.
initially.
Hence (C) is correct option.

Question. 47

Which of the following statements about synchronous and


asynchronous I/O is NOT true?
(A) An ISR is invoked on completion of I/O in synchronous I/O but
not in asynchronous I/O
(B) In both synchronous and asynchronous I/O an ISR (Interrupt
Serive Routine) is invoked
invoked after completion of the I/O
(C) A process making a synchronous I/O cal waits until I/O is
complete, but a process making an asynchronous I/O call does
not wait for completion of the I/O
Page 29
CS Topicwise 2001-2010
Operating System [Link]

(D) In the case of synchronous I/O, the process waiting for the
completion of I/O is woken up by the ISR that is invoked afterr
the completion of I/O

SOLUTION

For the completion of I/0 an interrupt should be generated for CPU


in case of both synchronous & asynchronous I/0 and this ISR call is
before them.
So CPU can switch to I/0.
Hence (B) is correct option.

Question. 48

Which of the following is NOT true of deadlock prevention and


deadlock avoidance schemes?
(A) In deadlock
deadlo ck prevention, the request for resources is alway
alwayss granted
if the resulting state is safe
(B) In deadlock avoidance, the request for resources is always granted
granted
if the resulting state is safe
(C) Deadlock avoidance is less restrictive than deadlock
deadlo ck prevention
prevention
(D) Deadlock avoidance requires knowledge of resource requirements
a priori

SOLUTION

Both deadlock prevention, & avoidance allocate resources if the


resulting state is safe state so option
opt ion (A) & (B) are tree. The difference
in both schemes is that in avoidance we knowknow the requirement a prior.
But Deadlock avoidance is less restrictive than prevention is false.
Hence (C) is correct option.

Question. 49

A process executes the following code for(


for(i = 0' i < n; i + +)fork();
The total number of child processes created is
(A) n (B) 2n − 1
(C) 2n (D) 2n + 1 − 1

Page 30
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

The loop is called for n times. The first process is parent process so
this should not be
b e counted in child process. But after
aft er that every child
process has its own child created so after every loop.
0 n

2 , 2',..
,.........2 total threads.
But subtracting the parent.
Hence (B) is correct option.

Question. 50

A processor uses 36 bit physical addresses and 32 bit virtual addresses,


with a page frame size of 4 Kbytes. Each page table entry is of size 4
bytes. A three level page table is used for virtual-to-physical address
translation, where the virtual address is used as follows
: bits 30-31 are used to index into the first level page table,

: bits 21-29 are used to index into second level page table
: bits 12-20 are used to index into third level page table
: bits 0-11 are used as offset within the page
The number of bits required for addressing the next level page table
(or page frame) in the page table entry of the first, second and third
level page table are respectively
respect ively..
(A) 20,20 and 20 (B) 24,24 and 24
(C) 24,24 and 20 (D) 25,25 and 24

SOLUTION

Total address single = 36 bit


First level no. of bits = 2 # 12 = 24 bits
Second level = 4 # 6 = 24 bits
Third level = 8 # 3 = 24 bits
Hence (B) is correct option.

YEAR 2009

Question. 51

Consider a system with 4 type of resources


resou rces R1 (3 units), R2 (2 units),
u nits),
R3 (3 units), R4 (4units). A non-preemptive resource allocation
policy is used. At any give instance, a request is not entertained if it
Page 31
CS Topicwise 2001-2010
Operating System [Link]

cannot be completely satisfied. Three processes P1, P2, P3 request


the resources as follows if executed independently
independently..

Process P1: Process P2: Process P3


t=0; requests 2 units of R2 t=0 : request 2 units of R3 t=0 ; request 1 units of R4

t=0; request 1 units of R3 t=2 ; request 1 units of R4 t=2 ; request 2 units of R1


t=4 ; request 1 units of R1 t=5 ; release 2 units of R1
t=0; request 2 units of R1 t=6 ; release 1 units of R3 t=8 ; request 1 units of R3
t=5; release 1 unit of R2 t=8 ; Finishes t=9 ; Finishes
and 1 units of R1
t=7; release 1 units of R3
t=8; request 2 units of R4
t=10; Finishes

Which one of the following statements is TRUE if all three processes


pro cesses
run concurrently starting at time t = 0 ?
(A) All processes will finish without any deadlock

(B) Only P1 and P2 will be in deadlock


(C) Only P1 and P3 will be in deadlock
(D) All three processes will be in deadlock

SOLUTION

Tot
otal
al re
reso
sour
urces
ces = 3 2 3 2
Proc
Proceess 1 Proc
oces
esss 2 Proc
oceess 3 Avai
aillable
Time 1 2 3 4 1234 1234 1234
0 0200 0020 0001 3011
1 0210 0020 0001 3001
2 0210 0021 2001 1000
3 0210 0021 2001 1000
4 0210 1021 2001 0000
5 1110 1021 0001 1100
6 1110 1011 0001 1110
7 1100 1011 0101 1020
8 1100 0000 0111 2021
9 1102 0000 0000 2130
10 0000 0000 0000 3232
All process computed without deadlock
Hence (A) is correct option.
Page 32
CS Topicwise 2001-2010
[Link] Operating System

Question. 52

In which of the following page replacement policies,


p olicies, Belady’s anomaly
may occur ?
(A) FIFO (B) Optimal
(C) LRU (D) MRU

SOLUTION

Belady’s anomaly is a properly of FIFO page replacement policy in


which the no. of page faults increases even if the no. of page frames
are increased in some cases.
Hence (A) is correct option.

Question. 53

The essential content(S) in each entry of a page table is/are


(A) virtual page number
(B) page frame number
(C) Both virtual page number and page frame number
(D) access right information

SOLUTION

A page table is in main memory which mop a page frame to a virtual


memory page.
So essential content is page frame number
Hence (B) is correct option.

Question. 54

Consider a disk system with 100 cylinders. The requests to access the
cylinders occur in following sequence :
4, 34, 10, 7, 19, 73, 2, 15, 6, 20
Assuming that the head is currently at cylinder 50, what is the time
taken to satisfy all requests if it takes 1 ms to move from one cylinder
to adjacent one and shortest seek time first policy is used ?

(A) 95 ms (B) 119 ms


(C) 233 ms (D) 276 ms
Page 33
CS Topicwise 2001-2010
Operating System [Link]

SOLUTION

Arranging in order.

Total 16 + 14 + 1 + 4 + 5 + 3 + 1 + 2 + 2 + 71
=
= 119 ms
Hence (B) is correct option.

Question. 55
In the following process state transition diagram for a uniprocessor
system, assume that there are always some processes in the steady
state :

Now consider the following statements :


I. If a process makes a transition D, itit would
would result in another
process making transition A immediately
II A process P2 in blocked state can make transition E while another
process P1 is in running state
III The OS uses non-premptive scheduling
IV The OS uses non-premptive
non-premptive scheduling
scheduling
Which of the above statement are TRUE ?
(A) I and II (B) I and III
(C) II and III (D) II and IV
Page 34
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

I Is not necessary that a new process enters immediately


immediately..
II Is true different process can be in different states one is ready
and another in running state.
III Is also correct since if one blocked it stop running so other can
run.
IV Is not correct.
Hence (C) is correct option.

Question. 56

The enter_CS ( ) and leave_CS ( ) functions to implement critical


section of a process are realized using test and set instruction as
follows :
Void enter_cs (X)
{
while (test-and-set)(X)) :
}
Void leave_CS(X)
{
X=0;
}
In the above solution, X is a memory location associated with the CS
and is initialized to 0. Now consider the following statements
I The above solution to CS problem is deadlock-free

II The solution is starvation free


III The processes enter CS in FIFO order
IV More than one process can enter CS at the same time
Which of the above
ab ove statements are TRUE
(A) I only (B) I and II
(C) II and III (D) IV only

SOLUTION

I Is true since X is initialized to zero, this cause only 1 process


pro cess to enter
into critical so no deadlock.
II & III Are false, other process which doesn’t capture X will wait
so ultimately starve.
Page 35
CS Topicwise 2001-2010
Operating System [Link]

IV Since I true so it is false.


Hence (A) is correct option.

Question. 57

A multilevel
page table forpage table isvirtual
translating preferred in comparison
address to physical to a single
address level
because
(A) It reduces the memory access time to read or write and memory
location
(B) It helps to reduce the size of page table needed to implement the
virtual address space of a process
(C) If is required by the translation lookaside buffer
(D) If helps to reduce the number of page faults in page replacement
algorithms.

SOLUTION

Single level page table is not preferred since it requires the no. of
page table enteries equal to the no. of virtual memory addresses, but
a multilevel page table has smaller no. of enteries so reduce the size
of page table needed.
Hence (B) is correct option.

YEAR 2010

Question. 58

Consider the sections


their critical methodswhenever
used by needed,
processesasP1 andbelow.
given P2 forThe
accessing
initial
values of shared boolean variables S1 and S2 are randomly assigned.
Meth
Method
od us
used
ed by P1
P1 Meth
Method
od us
used
ed by P2
P2
While (S1==S2); While (S1!=S2);
Critical Section Critical Section
S1=S2; S2=not (S1)
While one of the following
fo llowing statements describes properties achieved ?
(A) Mutual exclusion nut nor progress
(B) Progress but not mutual exclusion
(C) Neither mutual exclusion nor progress
(D) Both mutual exclusion and progress
Page 36
CS Topicwise 2001-2010
[Link] Operating System

SOLUTION

Method used by P1 & P2 enters into critical section when S1 = S2 &


S1 ! = S2 respectively, since both are opposite conditions so mutual
exclusion is there, but if P1 's while loop true then it will always be
true & in P2 if while loop true it would run infinitely so no. progress.
Hence (A) is correct option.

Question. 59

A system uses FIFO policy for page replacement. It has 4 page frames
with no pages loaded to begin with . The system first accesses 100
distinct pages in some order and then accesses the same 100 pages
but now in the reverse order .How many page faults will occur ?
(A) 196 (B) 192
(C) 197 (D) 195

SOLUTION

In FIFO page replacement policy, the pages which entered first are
replaced first so for first 100 accesses, 100
1 00 page faults will occur. Now
N ow
th
in memory there are last 4 pages 97, 98, 99 & 100 page.
So during reverse access there 4 pages would not create any page
fault & other 97 page faults.
So total 100 + 96 = 196 page faults.
Hence (A) is correct option.

Question. 60

Which of the following statements are true ?


I Shortest remaining time first scheduling may cause starvation
II Preemptive scheduling may cause starvation
II Round robin in better than FCFS in terms of response time
(A) I only (B) I and III only
(C) II and III only (D) I, II and III

SOLUTION

I SRIF scheduling may cause starvation since the processes which


require large CPU burst periods
p eriods would have to wait.
II Generally preemptive scheduling doesn’t cause starvation but
Page 37
CS Topicwise 2001-2010
Operating System [Link]

in some cases, it may cause starvation when one process doesn’t


block due to I/O so others have to wait.
III It is quite obvious
obvious that due to preemption involv
involvement
ement round
orbit is better than FCFS, in case of response time.

All are true


Hence (D) is correct option.

Question. 61

The following program consists of 3 concurrent precesses and 3 binary


semaphores. The semaphores are initialized as S 0 = 1, S1 = 0, S2 = 0

Process P0 Process P1 Process P2


While (true){ wait (S1 ); wait (S2 )
wait (S 0 ); release (S 0 ); release (S 0 );
print ‘0’

release (S1 );
release (S2 );
}
How many times will precess P0 print ‘0’ ?
(A) At least twice (B) Exactly twice
(C) Exactly thrice (D) Exactly once

SOLUTION

Let us see what will happen initially S 0 = 1, S1 = 0 S2 = 0 so P1 & P2


will wait & P0 runs & make S 0 = 0 wait decrements semaphore by 1
& release increments if by 1.
So after P0 's 1 st run S1 = 1 & S 2 = 1 ‘0’ is printed
Now P1 & P2 can run & make S1 = 0 , S2 = 0 but both increments
S 0 = 1 again.
So P0 again starts and print '0' so this would continue again & again.
So '0' will be printed
printed at least
least twice.
twice.
Hence (A) is correct option.

Question. 62

A system has n resources R0. . Rn - 1, and k processes P0. . Pk - [Link]


implementation of the resource request logic of each process Pi , is as
follows:

Page 38
CS Topicwise 2001-2010
[Link] Operating System

if (i%2==0){

if(i<n)request i ;

if(i+2<n)request i + 2;

else {

if (i<n)request  n  ;

if (i+2<n)request  n  i  2;

In which one of the following situations is a deadlock possible ?

(A) n = 40, k = 26 (B) n = 21, k = 12

(C) n = 20, k = 10 (D) n = 41, k = 19

SOLUTION

Allotment of resources would be successful to all cases but in option

(B) where n = 21 & k = 12 .

Let use take i = 10

So for P10 only R10 can be allotted whereas for P11 odd case (else).

R21 − 11 i.e R10 can only be allotted.

This is an conflict.

Hence (B) is correct option.

Page 39
By NODIA and Company
Available
Available in Two
Two Volumes
Volumes

You might also like