You are on page 1of 83

OPERATING SYSTEM GATE-PSUs-UGC-NET

GATE – UGC-NET
Question Practice with Answer

for

Operating System
Computer Science & Information Technology

By

Siddharth Shukla
[BE(CSE), M.Tech.(CTA), PhD*]
Ex. Faculty : BIT-Durg
Director – iGate Bhilai

website: www.igate.guru

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[1]
OPERATING SYSTEM GATE-PSUs-UGC-NET

INTRODUCTION
Q.1 A user level process in Unix traps the signal sent on a Ctrl+C input, and has a signal
handling routine that saves appropriate files before terminating the process. When a
Ctrl+C input is given to this process, what is the mode in which the signal handling
routine executes? [NET June 2012]
(A) User mode (B) Kernel mode (C) Superuser mode (D) Privileged mode

Q.2 What is the size of the Unicode character in Windows Operating System?
(A) 8-Bits (B) 16-Bits (C) 32-Bits (D) 64-Bits
[NET Dec. 2012]

Q.3 Which of the following features will characterize an OS as multi-programmed OS?


a. More than one program may be loaded into main memory at the same time.
b. If a program waits for certain event another program is immediately scheduled
c. If the execution of a program terminates, another program is immediately scheduled
(A) a only (B) a and b only (C) a and c only (D) a, b, and c only
[NET Dec. 2012]

Q.4 In Win32, which function is used to create Windows Applications? [NET Dec. 2012]
(A) Win APP (B) Win API (C) Win Main (D) Win Void

Q.5 Everything below the system call interface and above the physical hardware is known as
(A) Kernel (B) Bus (C) Shell (D) Stub
[NET Dec. 2012]

Q.6 Which of the following operating system is better for implementing client-server
network? [NET Dec. 2012]
(A) Windows 95 (B) Windows 98 (C) Windows 2000 (D) All of these

Q.7 Which of the following is the correct value returned to the operating system upon the
successful completion of a program? [NET June 2014]
(A) 0 (B) 1
(C) –1 (D) Program do not return a value.

Q.8 For switching from a CPU user mode to the supervisor mode following type of interrupt
is most appropriate [NET Dec. 2014]
(A) Internal interrupts (B) External interrupts
(C) Software interrupts (D) None of the above

Q.9 In a distributed computing environment, distributed shared memory is used which is


(A) Logical combination of virtual memories on the nodes. [NET Dec. 2014]
(B) Logical combination of physical memories on the nodes.
(C) Logical combination of the secondary memories on all the nodes.
(D) All of the above

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[2]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.10 Which of the following computing models is not an example of distributed computing
environment? [NET Dec. 2014]
(A) Cloud computing (B) Parallel computing
(C) Cluster computing (D) Peer-to-peer computing

Q.11 Match the following for operating system techniques with the most appropriate
advantage: [NET June 2015]
List - I List - II
(i) Allows several jobs in memory to improve CPU
(a) Spooling
utilization
(ii) Access to shared resources among geographically
(b) Multiprogramming
dispersed computers in a transparent way
(c) Time sharing (iii) Overlapping I/O and computations
(iv) Allows many users to share a computer
(d) Distributed computing
simultaneously by switching processor frequently
(A) a–iii, b–i, c–ii, d–iv (B) a–iii, b–i, c–iv, d–ii
(C) a–iv, b–iii, c–ii, d–i (D) a–ii, b–iii, c–iv, d–i

Q.12 Match the following for unix system calls: [NET June 2015]
List-I List-II
a. exec i. Creates a new process
b. brk ii. Invokes another program overlaying memory space with a copy of an
executable file
c. wait iii. To increase or decrease the size of data region
d. fork iv. A process synchronizes with termination of child process
(A) a-ii, b-iii, c-iv, d-i (B) a-iii, b-ii, c-iv, d-i
(C) a-iv, b-iii, c-ii, d-i (D) a-iv, b-iii, c-i, d-ii

Q.13 System calls are usually invoked by using [NET Dec. 2015]
(A) A privileged instruction (B) An indirect jump
(C) A software interrupt (D) Polling

Q.14 Distributed operating systems consist of: [NET Jan. 2017]


(A) Loosely coupled O.S. software on a loosely coupled hardware.
(B) Loosely coupled O.S. software on a tightly coupled hardware.
(C) Tightly coupled O.S. software on a loosely coupled hardware.
(D) Tightly coupled O.S. software on a tightly coupled hardware.

Q.15 Names of the some of the operating systems are given below: [NET Jan. 2017]
a. MS-DOS b. XENIX c. OS/2

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[3]
OPERATING SYSTEM GATE-PSUs-UGC-NET

In the above list, following operating systems did not provide multiuser facility
(A) a only (B) a and b only (C) b and c only (D) a, b, and c

Q.16 In Distributed system, the capacity of a system to adapt the increased service load is
called __________ . [NET Nov. 2017]
(A) Tolerance (B) Scalability (C) Capability (D) Loading

Q.17 In a multi-user operating system, 30 requests are made to use a particular resource per
hour, on an average. The probability that no requests are made in 40 minutes, when
arrival pattern is a poisson distribution, is _________. [NET July 2018]
–15 –15 –20
(A) e (B) 1 – e (C) 1 – e (D) e–20

Q.18 Normally user programs are prevented from handling I/O directly by I/O instructions in
them. For CPUs having explicit I/O instructions, such I/O protection is ensured by having
the I/O instructions privileged. In a CPU with memory mapped I/O, there is no explicit
I/O instruction. Which one of the following is true for a CPU with memory mapped I/O?
(A) I/O protection is ensured by operating system routine (s) [NET July 2018]
(B) I/O protection is ensured by a hardware trap
(C) I/O protection is ensured during system configuration
(D) I/O protection is not possible

ANSWER KEY
1. (A) 2. (B) 3. (B) 4. (C) 5. (A) 6. (C)
7. (A) 8. (C) 9. (B) 10. (B) 11. (B) 12. (A)
13. (C) 14. (C) 15. (A) 16. (B) 17. (D) 18. (A)

SOLUTION
Sol.1 A
 When an user send an input to the process it cannot be in privileged mode as it is
coming from an user so option D, Privileged mode cannot be possible here.
Now see, kernel mode = Privileged mode
 That means both option B and option D are equal. As option D cannot be possible,
option B also false.
 There is nothing called superuser mode so option C is clearly wrong.
 Only option A is left, when an user input come like ' ctrl+c' the signal handling
routine executes in user mode only as a user level process in UNIX traps the signal.
Hence option A is correct answer.

Sol.2 Ans. B 16 bits.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[4]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.3 (A) and (B) suffice multi programming concept. For multi programming more than one
program should be in memory and if any program goes for Io another can be scheduled
to use CPU as shown below:
So ans is (B).

Sol.4 Win Main


Win main is the function which is provided to create windows application .The user-
provided entry point for a graphical Windows-based application.

Sol.5 Kernel
A system call, sometimes referred to as a kernel call, is a request by an active process
made via a software interrupt for a service performed by the kernel.
The system call interface is the basic interface between a program and the kernel

A kernel is the central part of an operating system. It manages the tasks of the computer
and the hardware - most notably memory and CPU time. There are two types of kernels:
A microkernel, which only contains basic functionality; A monolithic kernel, which
contains many drivers.

Sol.6 Windows 2000


Among first 3 options windows 2000 is the latest one and we already have MS Server
2000 to provide such Facilities.

Sol.7 (A) After successful completion of a program 0 is returned to the operating system.

Sol.8 Ans will be C


as internal interrupts occur due to some internal error (like division by zero)
external interrupts occur due some h/w event like power failure etc
software interrupts or system calls are the most appropriate method for switching from a
user mode to kernel mode

Sol.9 ans should be B only physical memory is combined logically in distributed system

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[5]
OPERATING SYSTEM GATE-PSUs-UGC-NET

In, distributed shared memory (DSM) is a form of memory architecture where the
(physically separate) memories can be addressed as one (logically shared) address space.
Here, the term "shared" does not mean that there is a single centralized memory but
"shared" essentially means that the address space is shared (same physical address on
two processors refers to the same location in memory). Distributed global address
space (DGAS), is a similar term for a wide class of software and hardware
implementations, in which each node of a cluster has access to shared memory in
addition to each node's non-shared private memory.

Sol.10 ans. should be B


rest are different types of distributed computing
The two concepts parallel computing and distributed computing are very closely related;
they mostly come from very different backgrounds.
Parallel computing means that different activities happen at the same time. The term was
mostly used in scientific computing (consumer computers until very recently simply
were not parallel) where it typically means: spread out a single application over many
cores/processors/processes to get it done bigger/faster. Current big parallel computers
have 100 thousand to a million parallel processors/cores/threads/whatever.
Distributed computing comes from the business world where you have distributed
systems such as airline reservation systems, where many people access and modify the
same data at the same time. The machinery involved here is typically much looser
coupled, and the activities in a distributed system are typically far less synchronized

Sol.11 Ans. is B
Spooling--- Overlapping I/O and computations
Multiprogramming--- Allows several jobs in memory to improve CPU utilization
Time sharing---Allows many users to share a computer simultaneously by switching
processor frequently
Distributed computing---Access to shared resources among geographically dispersed
computers in a transparent way

Sol.12 Ans. should be A


1. In UNIX Wait() is used to Wait For Single Object() .
2. In UNIX Fork() is used for create-process().
3. In UNIX Create() is used for Create File().
4. In UNIX Close() is used for Close Handle()
So, option (A) is correct.

Sol.13 Software interrupt is the answer.


Privileged instruction cannot be the answer as system call is done from user mode and
privileged instruction cannot be done from user mode.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[6]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.14 Distributed operating systems consist of tightly coupled O.S. software on a loosely
coupled hardware.
So, option (C) is correct.

Sol.15 MS-DOS originally single user, multi-user support retrofitted


XENIX always been multi-user
OS/2 Always been Single user, while later versions added multi-user support but when
multi-user support added then the name of OS was changed to 'OS/2 warp' and 'Windows
NT; based on these safest choice is option A, 'a only'. Because option B, C, D has
'b. XENIX' which has been a multi-user OS from start.

Sol.16 Scalability is the capacity of distributed system to adopt the increased load.
Distributed_System
So, option (B) is correct.

Sol.18 User applications are not allowed to perform I/O in user mode – All I/O requests are
handled through system calls that must be performed in kernel mode.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[7]
OPERATING SYSTEM GATE-PSUs-UGC-NET

PROCESS & THREADS


Q.1 A thread is a light weight process. In the above statement, weight refers to
(A) Time (B) Number of resources
(C) Speed (D) All of the above [NET Dec. 2012]

Q.2 Let the time taken to switch between user mode and kernel modes of execution be t1
while the time taken to switch between two user processes be t2. Which of the following
is TRUE? [NET June 2013]
(A) t1 < t2
(B) t1 > t2
(C) t1 = t2
(D) Nothing can be said about the relation between t1 and t2

Q.3 A thread is usually defined as a light weight process because an Operating System (OS)
maintains smaller data structure for a thread than for a process. In relation to this, which
of the following statement is correct? [NET June 2013]
(A) OS maintains only scheduling and accounting information for each thread
(B) OS maintains only CPU registers for each thread
(C) OS does not maintain virtual memory state for each thread
(D) OS does not maintain a separate stack for each thread

Q.4 A specific editor has 200 K of program text, 15 K of initial stack, 50 K of initialized data,
and 70 K of bootstrap code. If five editors are started simultaneously, how much physical
memory is needed if shared text is used? [NET Dec.2014]
(A) 1135 K (B) 335 K (C) 1065 K (D) None of these

Q.5 Which methods are utilized to control the access to an object in multi-threaded
programming? [NET Dec. 2014]
(A) Asynchronized methods (B) Synchronized methods
(C) Serialized methods (D) None of the above

Q.6 One of the disadvantages of user level threads compared to Kernel level threads is
(A) If a user level thread of a process executes a system call, all threads in that process
are blocked.
(B) Scheduling is application dependent.
(C) Thread switching doesn’t require kernel mode privileges.
(D) The library procedures invoked for thread management in user level threads are local
procedures. [NET Jan. 2017]

Q.7 User level threads are threads that are visible to the programmer and are unknown to the
kernel. The operating system kernel supports and manages kernel level threads. Three
different types of models relate user and kernel level threads.
Which of the following statements is/are true? [NET Nov. 2017]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[8]
OPERATING SYSTEM GATE-PSUs-UGC-NET

(a) (i) The Many – to – one model maps many user threads to one kernel thread
(ii) The one – to – one model maps one user thread to one kernel thread
(iii) The many – to – many model maps many user threads to smaller or equal
kernel threads
(b) (i) Many – to – one model maps many kernel threads to one user thread
(ii) One – to – one model maps one kernel thread to one user thread
(iii) Many – to – many model maps many kernel threads to smaller or equal user
threads
(A) (a) is true; (b) is false (B) (a) is false; (b) is true
(C) Both (a) and (b) are true (D) Both (a) and (b) are false

ANSWER KEY
1. (B) 2. (A) 3. (C) 4. (B) 5. (B) 6. (A)
7. (A)
SOLUTION
Sol.1 A thread is a light weight Process.
We might call it that way because a thread, like a process, is a way to have a parallel,
concurrent, flow of execution. But contrary to a process, a thread shares the same
memory as the other threads in the same process, instead of having a completely separate
memory.
Hence, Option (B) Number of resource is the correct choice.

Sol.2 Process switches or Context switches can occur in only kernel mode. So for process
switches first we have to move from user to kernel mode. Then we have to save the PCB
of the process from which we are taking off CPU and then we have to load PCB of the
required process. At switching from kernel to user mode is done. But switching from user
to kernel mode is a very fast operation (OS has to just change single bit at hardware
level)
Thus T1< T2

Sol.3 Answer to this question is (C).


Many of you would not agree at first so here I explain it how.
OS, on per thread basis, maintains ONLY TWO things: CPU Register state and Stack
space. It does not maintain anything else for individual thread. Code segment and Global
variables are shared. Even TLB and Page Tables are also shared since they belong to
same process.
A. option (A) would have been correct if 'ONLY' word were not there. It NOT only
maintains register state BUT stack space also.
B. is obviously FALSE

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[9]
OPERATING SYSTEM GATE-PSUs-UGC-NET

C. is TRUE as it says that OS does not maintain VIRTUAL Memory state for individual
thread which is TRUE
D. This is also FALSE.

Sol.4 Answer is B,
Because text is shared so no need to multiply 200 with 5.and other need each for running
so answer is 200 + 15 + 50 + 70 = 335

Sol.5 ans. is B
With respect to multi-threading, synchronization is the capability to control the access of
multiple threads to shared resources. Without synchronization, it is possible for one Java
thread to modify a shared variable while another thread is in the process of using or
updating same shared variable. This usually leads to erroneous behavior or program.

Sol.6 Advantage of User level thread:


1- Scheduling is application dependent.
2- Thread switching doesn’t require kernel mode privileges.
3- The library procedures invoked for thread management in user level threads are local
procedures.
4- User level threads are fast to create and manage.
5- User level thread can run on any operating system.
disadvantage of User level thread
1- Most system calls are blocked on typical OS.
2- Multiprocessing is not supported for multi-threaded application.
So, Option (A) is correct.

Sol.7 option (A) is correct.


(a)
(i) The Many – to – one model maps many user threads to one kernel thread
(ii) The one – to – one model maps one user thread to one kernel thread
(iii) The many – to – many model maps many user threads to smaller or equal kernel
threads
(b)
(i) Many – to – one model maps many kernel threads to one user thread
(ii) One – to – one model maps one kernel thread to one user thread
(iii) Many – to – many model maps many kernel threads to smaller or equal user threads
All statement are correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[10]
OPERATING SYSTEM GATE-PSUs-UGC-NET

PROCESS SCHEDULING
Q.1 Pre-emptive scheduling is the strategy of temporarily suspending a running process
(A) before the CPU time slice expires (B) to allow starving processes to run
(C) when it requires I/O (D) to avoid collision [NET June 2012]

Q.2 In round robin CPU scheduling as time quantum is increased the average turn around
time [NET June 2012]
(A) Increases (B) Decreases (C) Remains constant (D) Varies irregularly

Q.3 The problem of indefinite blockage of low-priority jobs in general priority scheduling
algorithm can be solved using: [NET Dec. 2012]
(A) Parity bit (B) Aging (C) Compaction (D) Timer

Q.4 Consider n processes sharing the CPU in a round-robin fashion. Assuming that each
process switch takes s seconds, what must be the quantum size q such that the overhead
resulting from process switching is minimized but, at the same time, each process is
guaranteed to get its turn at the CPU at least every t seconds? [NET Dec. 2012]
t  ns t  ns t  ns t  ns
(A) q  (B) q  (C) q  (D) q 
n 1 n 1 n 1 n 1

Q.5 Consider the following processes with time slice of 4 milliseconds (I/O requests are
ignored): [NET June 2013]
Process A B C D
Arrival time 0 1 2 3
CPU Cycle 8 4 9 5
The average turnaround time of these processes will be
(A) 19.25 milliseconds (B) 18.25 milliseconds
(C) 19.5 milliseconds (D) 18.5 milliseconds

Q.6 Consider a preemptive priority based scheduling algorithm based on dynamically


changing priority. Larger priority number implies higher priority. When the process is
waiting for CPU in the ready queue (but not yet started execution), its priority changes at
a rate a = 2. When it starts running, its priority changes at a rate b = 1. All the processes
are assigned priority value 0 when they enter ready queue. Assume that the following
processes want to execute: [NET Dec. 2013]
Process ID Arrival Time Service Time
P1 0 4
P2 1 1
P3 2 2
P4 3 1

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[11]
OPERATING SYSTEM GATE-PSUs-UGC-NET

The time quantum q = 1. When two processes want to join ready queue simultaneously,
the process which has not executed recently is given priority. The finish time of
processes P1, P2, P3 and P4 will respectively be
(A) 4, 5, 7 and 8 (B) 8, 2, 7 and 5 (C) 2, 5, 7 and 8 (D) 8, 2, 5 and 7

Q.7 Linux operating system uses [NET Dec. 2013]


(A) Affinity scheduling (B) Fair Preemptive Scheduling
(C) Hand Shaking (D) Highest Penalty Ratio Next

Q.8 Match the following: [NET June 2014]


List-I List-II
a. Multilevel feedback queue i. Time-slicing
b. FCFS ii. Criteria to move processes between queues
c. Shortest process next iii. Batch processing
d. Round robin scheduling iv. Exponential smoothening
(A) A–i; b–iii; c–ii; d–iv (B) A–iv; b–iii; c–ii; d–i
(C) A–iii; b–i; c–iv; d–ii (D) A–ii; b–iii; c–i; d–i

Q.9 Consider the following justifications for commonly using the two-level CPU scheduling:
I. It is used when memory is too small to hold all the ready processes.
II. Because its performance is same as that of the FIFO.
III. Because it facilitates putting some set of processes into memory and a choice is made
from that.
IV. Because it does not allow to adjust the set of in-core processes.
Which of the following is true? [NET Dec. 2014]
(A) I, III and IV (B) I and II (C) III and IV (D) I and III

Q.10 Which of the following statements is not true for Multi Level Feedback Queue processor
scheduling algorithm? [NET June 2015]
(A) Queues have different priorities
(B) Each queue may have different scheduling algorithm
(C) Processes are permanently assigned to a queue
(D) This algorithm can be configured to match a specific system under design

Q.11 Which of the following scheduling algorithms may cause starvation?


a. First-come-first-served [NET Jan. 2017]
b. Round Robin
c. Priority
d. Shortest process next
e. Shortest remaining time first
(A) a, c and e (B) c, d and e (C) b, d and e (D) b, c and d

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[12]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.12 Which module gives control of the CPU to the process selected by the short-term
scheduler? [NET Nov. 2017
(A) Dispatcher (B) Interrupt (C) Scheduler (D) Threading

Q.13 Consider the following four processes with the arrival time and length of CPU burst
given in milliseconds: [NET Nov.2017]
Process Arrival Time Burst Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5

The average waiting time or preemptive SJF scheduling algorithm is __________.


(A) 6.5 ms (B) 7.5 ms (C) 6.75ms (D) 7.75 ms

Q.14 Consider the following three processes with the arrival time and CPU burst time given in
milliseconds: [NET July2018]
Process Arrival Time Burst Time
P1 0 7
P2 1 4
P3 2 8
The Gantt Chart for preemptive SJF scheduling algorithm is _________.
(A) (B)

(C) (D)

Q.15 In which of the following scheduling criteria, context switching will never take place?
(A) Round robin (B) Preemptive SJF [NET July 2018]
(C) Non-preemptive SJF (D) Preemptive priority

ANSWER KEY
1. (B) 2. (D) 3. (B) 4. (A) 5. (B) 6. (*)
7. (B) 8. (D) 9. (D) 10. (C) 11. (B) 12. (A)
13. (A) 14. (B) 15. (C)

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[13]
OPERATING SYSTEM GATE-PSUs-UGC-NET

SOLUTION
Sol.1 Before the CPU time slice expires
In preemptive scheduling tasks are usually assigned with priorities. At times it is
necessary to run a certain task that has a higher priority before another task although it is
running. Therefore, the running task is interrupted for some time and resumed later when
the priority task has finished its execution. This is called preemptive scheduling.
In non-preemptive scheduling, a running task is executed till completion. It cannot be
interrupted.

Sol.2 There are few criteria’s used for measuring the performance of a particular scheduling
algorithm.
The turn around time is the interval of time between the submission of a process and its
completion.
The wait time is the amount of time a process has been waiting in the ready queue.
The response time is the time taken between the process submission and the first
response produced.
In RR algorithm, the value of time quantum or the time slice, plays a crucial role in
deciding how effective the algorithm is. If the time quantum is too small, there could be
lot of context switching happening which could slow down the performance. If the time
quantum is too high, then RR behaves like FCFS. If the time quantum is increased, the
average response time varies irregularly. If you take any comprehensive material on
operating system, you will come across a graph which depicts this behavior. So the
answer is option D.

Sol.3 A major problem with priority scheduling is indefinite blocking or starvation. A solution
to the problem of indefinite blockage of the low-priority process is aging. Aging is a
technique of gradually increasing the priority of processes that wait in the system for a
long period of time.
Hence, Option (B) Aging is the correct choice.

Sol.4 (A)
Each process runs for q period and if there are n process: p1, p2, p3, ....., pn,.
Then p1's turn comes again when it has completed time quanta for remaining process
p2 to pn, i.e, it would take at most (n−1)q time.
So,, each process in round robin gets its turn after (n−1)q time when we don't consider
overheads but if we consider overheads then it would be ns + (n − 1)q
So, we have ns + (n − 1) q ≤ t

Sol.5 Answer B
The system uses Round robin algorithm of time quantum = 4ms
|o A |4 B |8 C |12 D | 16 A |20 C|24| D |25 C |26
average turn around time = (Finished time- start time) of each process/ no of processes.
= (20 – 0) + (8 – 1) + (26 – 2) + (25 – 3) /4 = 18.25 ms
Sol.6 Following processes want to execute:

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[14]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Process ID Arrival Time Service time


P1 0 4
P2 1 1
P3 2 2
P4 3 1
Time Priority
0 p1 = 1,
1 p2 = 1, p1 = 2.
2 P2 = 2, p1 = 2, p3 = 0
3 P1 = 1, p3 = 2, p4 = 0
4 P3 = 1, p1 = 2, p4 = 2
5 P1 = 1, p3 = 2, p4 = 2
Gantt chart
0----p1---1-----p2----2-----p1-----3----p3---4---p4---5----p1---6----p3----7---p1---8.
P1 finishes at 8.
P2 at 2
P3 at 7
P4 at 5.

Sol.8 Option D
a. Multilevel feedback queue ------ ii. Criteria to move processes between queues
b. FCFS --------- iii. Batch processing
c. Shortest process next ------ iv. Exponential smoothening
d. Round robin scheduling --------- i. Time-slicing

Sol.9 The two-level CPU scheduling is used when memory is too small to hold all the ready
processes because it facilitates putting some set of processes into memory and a choice is
made from that.
So, option (D) is correct.

Sol.10 C is not true and hence is the ans.


Processes are not permanently assigned to a queue they can very between queues as their
priorities change
Rest C options are true

Sol.11 So, option (B) is correct.


1. In First Come First Serve (FCFS) if a process with a very large Burst Time comes
before other processes, the other process will have to wait for a long time but it is
clear that other process will definitely get their chance to execute, so it will not suffer
from starvation.
2. In Round Robin there is a fixed time quant and every process will get their chance to
be executed, so no starvation is here.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[15]
OPERATING SYSTEM GATE-PSUs-UGC-NET

3. In Priority based scheduling if higher priority process keep on coming then low
priority process will suffer from starvation.
4. In Shortest Job First(SJF) if process with short process time keep on coming
continuously then process with higher burst time will do wait and suffer from
starvation.
5. In Shortest remaining time first(SRTF) process with shortest burst time will execute
first because of this process with high burst time may suffer from starvation.

Sol.12 Dispatcher is the module that gives control of the CPU to the process selected by the
short-term scheduler. It receives control in kernel mode as the result of an interrupt or
system call.
answer : option A

Sol.13 First we will make gantt chart of given process then we will calculate turn around time
and waiting time of individual process.
P1 P2 P4 P1 P3
0 1 5 10 17 26
Process id CT TAT WT
P1 17 17 9
P2 5 4 0
P3 26 24 15
P4 10 7 2

Now we have to calculate average waiting time for schedule:


avg waiting time = wt(P1 + P2 + P3 + P4 )/number of process.
ie. (9 + 0 + 15 + 2) / 4 = 26 / 4 = 6.5
So, option (A) is correct.

Sol.14 P1 arrive at 0 it will be served by CPU for 1 unit. After 1 unit P2 arrived ans it is shortest
So it will execute for 4 unit, after its execution There are 2 processes out of which P1 is
shortest so it will execute for 6 unit after its execution P1 will execute for 8 unit.
Gantt chart for preemptive SJF scheduling algorithm is:

So, option (B) is correct.

Sol.15 Except Non-Preemptive SJF, All are Preemptive.


CPU will leave the Shortest Process only after its Full execution, Once process is started
to execute.
Option (C) is correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[16]
OPERATING SYSTEM GATE-PSUs-UGC-NET

PROCESS SYNCHRONIZATION
Q.1 Consider the methods used by processes P1 and P2 for accessing their critical sections
whenever needed, as given below. The initial values of shared boolean variables S1 and
S2 are randomly assigned. [NET June 2012]
P1 P2
while (S1 == S2); while (S1 != S2);
Critica1 Section Critica1 Section
S1 = S2; S2 = not (S1);
Which one of the following statements describes the properties achieved?
(A) Mutual exclusion but not progress (B) Progress but not mutual exclusion
(C) Neither mutual exclusion nor progress (D) Both mutual exclusion and progress

Q.2 Suppose S and Q are two semaphores initialized to 1. P1 and P2 are two processes which
are sharing resources. [NET June 2013]
P1 has statements P2 has statements
wait(S); wait(Q);
wait(Q); wait(S);
critical-section 1; critical-section 2;
signal(S); signal(Q);
signal(Q); signal(S);
Their execution may sometimes lead to an undesirable situation called
(A) Starvation (B) Race condition (C) Multithreading (D) Deadlock

Q.3 Which of the following conditions does not hold good for a solution to a critical section
problem? [NET Dec. 2014]
(A) No assumptions may be made about speeds or the number of CPUs.
(B) No two processes may be simultaneously inside their critical sections.
(C) Processes running outside its critical section may block other processes.
(D) Processes do not wait forever to enter its critical section.

Q.4 Monitor is an Interprocess Communication (IPC) technique which can be described as


(A) It is higher level synchronization primitive and is a collection of procedures,
variables, and data structures grouped together in a special package.
(B) It is a non-negative integer which apart from initialization can be acted upon by wait
and signal operations.
(C) It uses two primitives, send and receive which are system calls rather than language
constructs.
(D) It consists of the IPC primitives implemented as system calls to block the process
when they are not allowed to enter critical region to save CPU time.
[NET Dec. 2014]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[17]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.5 Let Pi and Pj two processes, R be the set of variables read from memory, and W be the set
of variables written to memory. For the concurrent execution of two
processes Pi and Pj which of the conditions are not true? [NET June 2015]
(A) R(Pi) ∩ W(Pj) = Φ (B) W(Pi) ∩ R(Pj) = Φ
(C) R(Pi) ∩ R(Pj) = Φ (D) W(Pi) ∩ W(Pj) = Φ

Q.6 Dining Philosopher's problem is a [NET June 2015]


(A) Producer - consumer problem (B) Classical IPC problem
(C) Starvation problem (D) Synchronization primitive

Q.7 In an operating system, indivisibility of operation means: [NET Dec. 2015]


(A) Operation is interruptable (B) Race Condition may occur
(C) processor cannot be pre-empted (D) All of the above

Q.8 There are three processes P1, P2 and P3 sharing a semaphore for synchronising a
variable. Initial value of semaphore is one. Assume that negative value of semaphore tells
us how many processes are waiting in queue. Processes access the semaphore in
following order: [NET Jan. 2017]
a. P2 needs to access
b. P1 needs to access
c. P3 needs to access
d. P2 exits critical section
e. Pi exits critical section
The final value of semaphore will be:
(A) 0 (B) 1 (C) –1 (D) –2

Q.9 Two atomic operations permissible on Semaphores are __________ and __________.
(A) wait, stop (B) wait, hold (C) hold, signal (D) wait, signal
[NET Nov. 2017]

Q.10 The Bounded buffer problem is also known as __________. [NET Nov. 2017]
(A) Producer – consumer problem (B) Reader – writer problem
(C) Dining Philosophers problem (D) Both (B) and (C)

Q.11 At a particular time of computation, the value of a counting semaphore is 10. Then 12 P
operations and “x” V operations were performed on this semaphore. If the final value of
semaphore is 7, x will be: [NET July 2018]
(A) 8 (B) 9 (C) 10 (D) 11

ANSWER KEY
1. (A) 2. (D) 3. (C) 4. (A) 5. (C) 6. (B)
7. (C) 8. (A) 9. (D) 10. (A) 11. (C)
SOLUTION

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[18]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.1 Answer is (A). In this mutual exclusion is satisfied, only one process can access the
critical section at particular time but here progress will not satisfied because suppose
when s1 = 1 and s2 = 0 and process p1 is not interested to enter into critical section
but p2 want to enter critical section. P2 is not able to enter critical section in this as only
when p1 finishes execution, then only p2 can enter (then only s1 = s2 condition be
satisfied).
Progress will not be satisfied when any process which is not interested to enter into the
critical section will not allow other interested process to enter into the critical
section. When P1 wants to enter the critical section it might need to wait till P2 enters
and leaves the critical section (or vice verse) which might never happen and hence
progress condition is violated.

Sol.2 Deadlock.
Suppose a condition when P1 executes wait(S) and makes S = 0. Now P2 executes
wait(Q) and makes Q = 0. Now neither P1 can execute wait(Q) nor P2 can execute
wait(S), because S and Q both are equal to 0. Now P1 is waiting for P2 to release
resource Q and P2 is waiting for P1 to release S. Hence neither of them can enter into
critical section and are in deadlock condition.

Sol.3 In Critical section problem:


 No assumptions may be made about speeds or the number of CPUs.
 No two processes may be simultaneously inside their critical sections.
 Processes running outside its critical section can’t block other processes getting enter
into critical section.
 Processes do not wait forever to enter its critical section.
Option (C) is correct.

Sol.4 A. Is ans.
monitor is a thread-safe class, object, or module that uses wrapped mutual exclusion in
order to safely allow access to a method or variable by more than one thread. The
defining characteristic of a monitor is that its methods are executed with mutual
exclusion: At each point in time, at most one thread may be executing any of its methods.
Using a condition variable(s), it can also provide the ability for threads to wait on a
certain condition (thus using the above definition of a "monitor"). For the rest of this
article, this sense of "monitor" will be referred to as a "thread-safe object/class/module".

Sol.5 For a concurrent execution there should be no read-write, write-write or write-read


conflict. as given option (a),(b) and (d) depicts the same which true option. C represent
the two simultaneous read operation of the process with no intersection variables which
may not be case.
hence C is false.
Sol.6 Answer must be B
The simple description of the problem:

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[19]
OPERATING SYSTEM GATE-PSUs-UGC-NET

 Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed
between each pair of adjacent philosophers.
 Each philosopher must alternately think and eat.
 However, a philosopher can only eat spaghetti when he has both left and right forks.
 Each fork can be held by only one philosopher and so a philosopher can use the fork
only if it is not being used by another philosopher.
 After he finishes eating, he needs to put down both forks so they become available to
others.
 A philosopher can take the fork on his right or the one on his left as they become
available, but cannot start eating before getting both of them.
 Eating is not limited by the remaining amounts of spaghetti or stomach space; an
infinite supply and an infinite demand are assumed.
 The problem is how to design a discipline of behavior (a concurrent algorithm) such
that no philosopher will starve; i.e., each can forever continue to alternate between
eating and thinking, assuming that no philosopher can know when others may want
to eat or think.

Sol.7 In an operating system, indivisibility of operation means processor can not be pre-
empted. One a process starts its execution it will not suspended or stop its execution
inside the processor.
So, option (C) is correct.

Sol.8 initial value of semaphores S = 1


1. P2 needs to access decreases it to 0 (no one is waiting)
2. P1 needs to access decreases it to –1 (one process is waiting)
3. P3 needs to access decreases it to –2 (2 process r waiting)
4. P2 exits critical section increases it to –1 (one process is waiting)
5. Pi exits critical section increases it to 0 (no process is waiting)
so ans. is A

Sol.9 Wait and signal are the atomic operation possible on semaphore.
So, (D) is the correct option.

Sol.10 The bounded buffer problem is also known as producer-consumer problem.


So, option (A) is correct.

Sol.11 Initially the value of a counting semaphore is 10 Now 12 P operation are performed.
Now counting semaphore value = –2
“x” V operations were performed on this semaphore and final value of counting
semaphore = 7
i.e. x + (–2) = 7
x = 9. So, option (C) is correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[20]
OPERATING SYSTEM GATE-PSUs-UGC-NET

DEADLOCKS
Q.1 Resources are allocated to the process on non-sharable basis is [NET June 2012]
(A) Mutual exclusion (B) Hold and wait (C) No pre-emption (D) Circular wait

Q.2 Consider a system having m resources of the same type. These resources are shared
by 3 processes A, B, and C which have peak demands of 3, 4 and 6 respectively. For
what value of m deadlock will not occur? [NET Dec. 2012]
(A) 7 (B) 9 (C) 10 (D) 13

Q.3 An operating system using banker’s algorithm for deadlock avoidance has ten dedicated
devices (of same type) and has three processes P1, P2 and P3 with maximum resource
requirements of 4, 5 and 8 respectively. There are two states of allocation of devices as
follows: [NET June 2013]
State 1 Processes P1 P2 P3
Devices allocated 2 3 4
State 2 Processes P1 P2 P3
Devices allocated 0 2 4
Which of the following is correct?
(A) State 1 is unsafe and State 2 is safe (B) State 1 is safe and State 2 is unsafe
(C) Both State 1 and State 2 are safe (D) Both State 1 and State 2 are unsafe

Q.4 Consider a system with five processes P0 through P4 and three resource types R1, R2 and
R3. Resource type R1 has 10 instances, R2 has 5 instances and R3 has 7 instances.
Suppose that at time T0, the following snapshot of the system has been taken:

Allocation Max Available


R1 R2 R3 R1 R2 R3 R1 R2 R3
P0 0 1 0 7 5 3 3 3 2
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 2 2 4 3 3
Assume that now the process P1, requests one additional instance of type R1 and two
instances of resource type R3. The state resulting after this allocation will be
[NET June 2014]
(A) Ready state (B) Safe state (C) Blocked state (D) Unsafe state

Q.5 An operating system has 13 tape drives. There are three processes P1, P2 & P3.
Maximum requirement of P1 is 11 tape drives, P2 is 5 tape drives and P3 is 8 tape drives.
Currently, P1 is allocated 6 tape drives, P2is allocated 3 tape drives and P3 is
allocated 2 tape drives. Which of the following sequences represent a safe state?
(A) P2 P1 P3 (B) P2 P3 P1 (C) P1 P2 P3 (D) P1 P3 P2
[NET Dec. 2014]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[21]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.6 A system has 4 processes and 5 allocatable resources. The current allocation and
maximum needs are as follows: [NET Dec. 2015]
Allocated Maximum Available
Process A 10211 11213 00x11
Process B 20110 22210
Process C 11010 21310
Process D 11110 11221
The smallest value of x for which the above system in safe state is
(A) 1 (B) 3 (C) 2 (D) 0

Q.7 Consider a system with twelve magnetic tape drives and three processes P1, P2 and P3.
process P1 requires maximum ten tape drives, process P2 may need as many as four tape
drives and P3 may need upto nine tape drives. Suppose that at time t1, process P1 is
holding five tape drives, process P2 is holding two tape drives and process P3 is holding
three tape drives, At time t1, system is in: [NET Dec 2015]
(A) safe state (B) unsafe state (C) deadlocked state (D) starvation state

Q.8 Suppose there are 4 processes in execution with 12 instances of a Resource R in a


system: [NET June 2016]
The maximum need of each process and current allocation are given below:
Process Max. Need Current Allocation
P1 8 3
P2 9 4
P3 5 2
P4 3 1
With reference to current allocation, is system safe? If so, what is the safe sequence?
(A) No (B) Yes, P1P2P3P4 (C) Yes, P4P3P1P2 (D) Yes, P2P1P3P4

Q.9 Consider a system with five processes P0 through P4 and three resource types A, B and C.
Resource type A has seven instances, resource type B has two instances and resource
type C has six instances suppose at time T0 we have the following allocation.

Process Allocation Request Available


A B C A B C A B C
P0 0 1 0 0 0 0 0 0 0
P1 2 0 0 2 0 2
P2 3 0 3 0 0 0
P3 2 1 1 1 0 0
P4 0 2 2 0 0 2

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[22]
OPERATING SYSTEM GATE-PSUs-UGC-NET

If we implement Deadlock detection algorithm we claim that system is __________.


[NET Nov. 2017]
(A) Semaphore (B) Deadlock State
(C) Circular Wait (D) Not in deadlock state

ANSWER KEY
1. (A) 2. (D) 3. (A) 4. (B) 5. (A) 6. (C)
7. (B) 8. (C) 9. (D)

SOLUTION
Sol.1 Mutual Exclusion
A mutual exclusion (mutex) is a program object that prevents simultaneous access to a
shared resource. This concept is used in concurrent programming with a critical section,
a piece of code in which processes or threads access a shared resource. Only one thread
owns the mutex at a time, thus a mutex with a unique name is created when a program
starts. When a thread holds a resource, it has to lock the mutex from other threads to
prevent concurrent access of the resource. Upon releasing the resource, the thread
unlocks the mutex.

Sol.2 13
Consider the worst scenario: all processes require one more instance of the resource.
So, P1 would have got 2, P2−3 and P3−5. Now, if one more resource is available at least
one of the processes could be finished and all resources allotted to it will be free which
will lead to other processes also getting freed. So, 2 + 3 + 5 = 10 would be the maximum
value of m so that a deadlock can occur.

Sol.3 Answer A
State 1:
Total number of devices allocated = 2+3+4 =9
No of devices available = 10-9 =1
 The no of devices still needed for P1 = 4-2 =2 >1 //Cannot allocate
 The no of devices still needed for P2 = 5-3 =2 >1 //Cannot allocate
 The no of devices still needed for P2 = 8-4 =4 >1 //Cannot allocate
State 1 is unsafe
state 2
Total number of devices allocated = 0+2+4 =6
No of devices available = 10-6 =4
 The no of devices still needed for P1 = 4-0 =4 =4 //Can allocate
 The no of devices still needed for P2 = 5-2 =3 <4 //Can allocate
 The no of devices still needed for P2 = 8-4 =4 =4 //Can allocate
State 2 is safe
Sol.4 option (b)

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[23]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Remaining
Process Allocation Max Available
Need
R1 R2 R3 R1 R 2 R3 R1 R2 R3 R 1 R2 R3
P0 0 1 0 7 5 3 7 4 3 3 3 2
P1 2 0 0 4 2 4 2 2 4
P2 3 0 2 9 0 2 6 0 0
P3 2 1 1 2 2 2 0 1 1
P4 0 2 2 4 3 3 4 1 1

initially need for process is 322 but process P1 requests one additional instance of type
R1 and two instances of resource type R3. with 332 we can satisfy p3 need therefore
giving all its allocated resource back resulting 5 4 3 now available resources. with 5 4 3
we can satisfy either p1 need or p4 need here we can’t satisfy p0 or p2 need because
remaining need resource are more than available resource so on ..... therefore there is
safe state with safe sequence as P3, P4, P1 , P2. P0

Sol.5 allocated Max need


P1 6 11 5
P2 3 5 2
total resource = 13 AND free resources =13–11= 2 so clearly these 2 can only be
given
P3 2 8 6
to P2 which will be completed and release its all 5 resource then next P1 can take 5
resource and be completed and finally P3
so right ans. is choice 1 P2P1P3

Sol.6 here need matrix for all process is given below (by (Max - allocated)
for A 0 1 0 0 2 B 0 2 1 0 0 C 1 0 3 0 0 D 0 0 1 1 1
available is 0 0 x 1 1
so only D can execute for any no of x as A,B or C need at least one instance of either of
first 2 resource
if x=1 then D can be executed and will release its allocated resource which is 1 1 1 1 0
then available matrix
will become 1 1 2 2 1 but with this neither of (A,B,C) process can be executed as
their need matrix is not less than or equal to available matrix so it will result in unsafe
state.
if x=2
then D can be executed and will release its allocated resource which is 1 1 1 1 0
then available matrix
will become 1 1 3 2 1 now Process C (with need 1 0 3 0 0 ) can be executed and
release its allocated resources
(1 1 0 1 0 ) and then

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[24]
OPERATING SYSTEM GATE-PSUs-UGC-NET

available matrix will become 2 2 3 3 1 so B can be executed and then A (assuming


one minor mistake in last resource) hence it is safe state
so ans. is C x = 2
Note :- process A cannot be executed for any no of x as its fifth resource need is 2 which
cannot be fulfilled

Sol.7 System is in UNSAFE state


 P1 holds 5 tapes
 P2 holds 2 tapes
 P3 holds 3 tapes
Total 10 tapes are allocated and 12-10=2 tapes are free
 P1 requires maximum 10 tape drives; It needs 10 – 5 = 5 more tapes
 P2 may need as many as 4tape drives. It needs 4 – 2 = 2 more tapes.
 P3 may need as many as 9 tape drives. It needs 9 – 3 = 6 more tapes.
We can allocate 2 free tapes to P2.
P2 will complete execution and release all its resources including 4 tapes.
Even if we allocate 4 tapes to P1 or P3 they cannot complete execution because P1 need
5 more taps while P3 needs 6 more tapes.
System is in unsafe state.

Sol.8 Answer C
 P1 holds 3 resources
 P2 holds 4 resources
 P3 holds 2 resources
 P4 holds 1 resource

Total 3 + 4 + 2 + 1 = 10 resources are allocated and 12 – 10 = 2 resources are free


 P1 requires maximum 8 resources; It needs 8 – 3 = 5 more tapes
 P2 requires maximum 9 resources; It needs 9 – 4 = 5 more tapes
 P3 requires maximum 5 resources; It needs 5 – 2 = 3 more tapes
 P4 requires maximum 3 resources; It needs 3 – 1 = 2 more tape
We can allocate 2 free resources to P4.
P4 will complete execution and release all its resources. Now total 3 resources are free.
We can allocate 3 free resources to P3.
P3 will complete execution and release all its resources. Now total 5 resources are free.
We can allocate 5 free resources to P1.
P1 will complete execution and release all its resources. Now total 8 resources are free.
We can allocate 5 free resources to P2.
P2 will complete execution and release all its resources.
System is in safe state.
The sequence is P4P3P1P2

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[25]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.9 The deadlock detection algo investigates every possible allocation sequences for the
processes that remain to be completed.
The total allocated resources to all processes of resource type B doesn't match with that
mentioned in the question. If we ignore the statement and take the tables as the right one
then the solution is as follows:
Process P0 and P2 have been allocated all its resources and hence will run till
completion. They will give up the resources they were allocated. This is the state:
Available: A = 3 B = 1 C = 3
Processes left: P1 P3 P4
Process P1 requires: A = 2 B = 0 C = 2
We can fulfill its request. It will be allocated all the resources and will run till
completion. Then it will give up all the resources. Now this will be the state:
Available: A = 5 B = 1 C = 3
Processes left: P3 P4
Similarly, next process P3 will be executed first and then P4.
Ans.: option D.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[26]
OPERATING SYSTEM GATE-PSUs-UGC-NET

MEMORY MANAGEMENT
Q.1 Given a memory partitions of 100 K, 500 K, 200 K, 300 K and 600 K (in order) and
processes of 212 K, 417 K, 112 K and 426 K (in order), using the first fit algorithm, in
which partition would the process requiring 426 K be placed? [NET Dec. 2012]
(A) 500 K (B) 200 K (C) 300 K (D) 600 K

Q.2 Which of the following memory allocation scheme suffers from external fragmentation?
(A) Segmentation (B) Pure demand paging
(C) Swapping (D) Paging [NET Dec. 2012]

Q.3 The process of assigning load addresses to the various parts of the program and adjusting
the code and data in the program to reflect the assigned address is called
(A) Symbol resolution (B) Parsing [NET Dec. 2013]
(C) Assembly (D) Relocation

Q.4 Translation Look-aside Buffer (TLB) is [NET Dec. 2013]


(A) A cache-memory in which item to be searched is compared one-by-one with the keys
(B) A cache-memory in which item to be searched is compared with all the keys
simultaneously
(C) An associative memory in which item to be searched is compared one-by-one with
the keys
(D) An associative memory in which item to be searched is compared with all the keys
simultaneously

Q.5 In a paged memory management algorithm, the hit ratio is 70%. If it taken 30ns to search
Translation Look-aside Buffer (TLB) and 100 nanoseconds (ns) to access memory, the
effective memory access time is [NET June 2014]
(A) 91 ns (B) 69 ns (C) 200 ns (D) 160 ns

Q.6 For the implementation of a paging scheme, suppose the average process size be x bytes,
the page size be y bytes, and each page entry requires z bytes. The optimum page size
that minimizes the total overhead due to the page table and the internal fragmentation
loss is given by [NET Dec. 2014]
x xz xz
(A) (B) (C) 2xz (D)
2 2 2

Q.7 Match the following with respect to various memory management algorithms:
[NET Dec. 2015]
List-I List-II
a. Demand paging i. degree of multiprogramming
b. Segmentation ii. working set

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[27]
OPERATING SYSTEM GATE-PSUs-UGC-NET

c. Dynamic partitions iii. supports user view of memory


d. Fixed partitions iv. compaction
(A) a–iii, b–iv, c–ii, d–i (B) a–ii, b–iii, c–i, d–iv
(B) a–iv, b–iii, c–ii, d–i (D) a–ii, b–iii, c–iv, d–i

Q.8 Function of memory management unit is: [NET Dec. 2015]


(A) Address translation (B) Memory Allocation
(C) Cache management (D) All of these

Q.9 In a paging system, it takes 30 ns to search translation Look-aside Buffer (TLB) and 90
ns to access the main memory. If the TLB hit ratio is 70%, the effective memory access
time is [NET Jan. 2017]
(A) 48 ns (B) 147 ns (C) 120 ns (D) 84 ns

Q.10 A memory management system has 64 pages with 512 bytes page size. Physical memory
consists of 32 page frames. Number of bits required in logical and physical address are
respectively: [NET Jan. 2017]
(A) 14 and 15 (B) 14 and 29 (C) 15 and 14 (D) 16 and 32

Q.11 In a paged memory, the page hit ratio is 0.40. The time required to access a page in
secondary memory is equal to 120 ns. The time required to access a page in primary
memory is 15 ns. The average time required to access a page is ________.
(A) 105 (B) 68 (C) 75 (D) 78
[NET July 2018]

Q.12 Which of the following statements are true? [NET July 2018]
(a) External Fragmentation exists when there is enough total memory space to satisfy a
request but the available space is contiguous.
(b) Memory Fragmentation can be internal as well as external.
(c) One solution to external Fragmentation is compaction.
Code:
(A) (a) and (b) only (B) (a) and (c) only
(C) (b) and (c) only (D) (a), (b) and (c)

Q.13 Page information in memory is also called as Page Table. The essential contents in each
entry of a page table is/are _________. [NET July 2018]
(A) Page Access information
(B) Virtual Page number
(C) Page Frame number
(D) Both virtual page number and Page Frame Number

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[28]
OPERATING SYSTEM GATE-PSUs-UGC-NET

ANSWER KEY
1. (*) 2. (A) 3. (D) 4. (D) 5. (D) 6. (C)
7. (D) 8. (A) 9. (B) 10. (C) 11. (D) 12. (C)
13. (C)

SOLUTION
Sol.1 426 cannot be placed. This question was removed from final answer keys published
officially

Sol.2 Answer: Segmentation


Segmentation is a technique to break memory into logical pieces where each piece
represents a group of related information.

Sol.3 Answer D Relocation


Relocation is the process of replacing symbolic references or names of libraries with
actual usable addresses in memory before running a program.
 It is typically done by the linker during compilation (at compile time)
 It can be done at runtime by a relocating loader.
 Compilers or assemblers typically generate the executable with zero as the lower-
most starting address. Before the execution of object code, these addresses should be
adjusted so that they denote the correct runtime addresses.
Relocation is typically done in two steps:
1. Each object code has various sections like code, data, etc. To combine all the objects to
a single executable, the linker merges all sections of similar type into a single section of
that type. The linker then assigns runtime addresses to each section and each symbol. At
this point, the code (functions) and data (global variables) will have unique runtime
addresses.
2. Each section refers to one or more symbols which should be modified so that they
point to the correct runtime addresses.

Sol.4 Translation Look-aside Buffer (TLB) is an associative memory in which item to be


searched is compared with all the keys simultaneously. When the associative memory is
presented with an item, the item is compared with all keys simultaneously. If the item is
found, the corresponding value field is returned.
D is ans.

Sol.5 We can assume single level paging and TLB look and page table look happens
sequentially meaning TLB look time is to be considered even for TLB miss. On a TLB
miss we need to access main memory for getting the physical address for the page table
before doing the actual memory access for the data.
Effective access time = Hit ratio*Time during hit + Miss Ratio * Time During Miss
= 0.7*(30 + 100) + 0.3 (30 + 100 + 100)
=91 + 69 = 160 ns

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[29]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Hence, Option (D) 160ns is the correct choice.

Sol.6 Average amount of internal fragmentation per segment is y/2.


Average no of pages per process segment is x/y.
Each page requires 'z' bytes of page table.
so each process segment requires page table size of xz/y bytes.
Total overhead per segment, therefore, due to internal fragmentation and page table
entries, is
xz/y + y/2
To minimise the overhead, differentiate with respect to page size, p, and equate to 0:
d(xz/y + y/2)/dy = –xz/y2 + 1/2 = 0
=> y = √(2xz)
Answer (C)
So for example, if the average segment size were 256K, and the page table entry size
were 8 bytes, the optimum page size, to minimise overhead due to page table entries and
internal fragmentation, would be sqrt(2 × 256K × 8) = 2048 = 2K.

Sol.7 is ans is (D)


a. Demand paging Working Set
b. Segmentation supports user view of memory
c. Dynamic partitions compaction
d. Fixed partitions degree of multiprogramming
Dynamic partion (variable partion): where external fragmentation is the problem and
solution is compaction
Fixed partitions: the degree of multiprograming is restricted by no of partitions in the
memory

Sol.8 Ans.: A
A memory management unit (MMU), sometimes called paged memory management
unit (PMMU), is a computer hardware unit having all memory references passed
through itself, primarily performing the translation of virtual memory
addresses to physical addresses.

Sol.9 70% TLB hit ratio 30 ns to search TLB


(0.7*30) in hit case: to find the page
0.3*(90+30) in miss case: to find the page
90 ns to access the data from main memory
so total time:
(0.7*30)+ (0.3*(90+30)) + 90 = 147
Sol.10 we know, Number of page = Virtual address space / Page size
so virtual address space = Number of page*page size

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[30]
OPERATING SYSTEM GATE-PSUs-UGC-NET

= 26*29 = 215
so we need 15 bit for VA
and Physical dress = Page size*frames = 29*25 = 214
so 14 bit required for PA
C is correct answer Here

Q.11 Average access time = hit ratio * primary memory access time + (1 – hit ratio) *
secondary memory access time
Average access time = 0.4 * 15 + 0.6 * 120
Average access time = 6 + 72
Average access time = 78.
So, option (D) is correct.

Sol.12 option (C) is correct.


 External Fragmentation exists when there is enough total memory space to satisfy a
request but the available space is contiguous. This is a false statement because
external fragmentation occurs due to non contiguous available space.
 Memory Fragmentation can be internal as well as external. True
 One solution to external Fragmentation is compaction or shuffle memory contents.
True

Sol.13 Page information in memory is also called as Page Table. The essential contents in each
entry of a page table is page frame number.
Option (C) is correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[31]
OPERATING SYSTEM GATE-PSUs-UGC-NET

VIRTUAL MEMORY
Q.1 Consider the following page trace: 4, 3, 2, 1, 4, 3, 5, 4, 3, 2, 1, 5
Percentage of page fault that would occur if FIFO page replacement algorithm is used
with number of frames for the JOB m = 4 will be [NET June 2012]
(A) 8 (B) 9 (C) 10 (D) 12

Q.2 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 memory entirely. Which one of
the following is true? [NET June 2012]
(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

Q.3 If an instruction takes i microseconds and a page fault takes an additional j microseconds,
the effective instruction time if on the average a page fault occurs every k instruction is:
(A) i + j/k (B) i + j * k (C) (i + j)/k (D) (i + j) * k
[NET June 2012]

Q.4 A virtual memory based memory management algorithm partially swaps out a process.
This is an example of [NET June 2013]
(A) Short term scheduling (C) Long term scheduling
(C) Medium term scheduling (D) Mutual exclusion

Q.5 Let the page fault service time be 10 milliseconds(ms) in a computer with average
memory access time being 20 nanoseconds (ns). If one page fault is generated
every 106 memory accesses, what is the effective access time for memory?
[NET June 2013]
(A) 21 ns (B) 30 ns (C) 23 ns (D) 35 ns

Q.6 A job has four pages A, B, C, D and the main memory has two page frames only. The job
needs to process its pages in following order: [NET June 2013]
ABACABDBACD
Assuming that the page interrupt occurs when a new page is brought in the main
memory, irrespective of whether the page is swapped out or not. The number of page
interrupts in FIFO and LRU page replacement algorithms are
(A) 9 and 7 (B) 7 and 6 (C) 9 and 8 (D) 8 and 6

Q.7 Working set model is used in memory management to implement the concept of
(A) Swapping (B) Principal of Locality
(C) Segmentation (D) Thrashing [NET June 2013]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[32]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.8 Consider a program that consists of 8 pages (from 0 to 7) and we have 4 page frames in
the physical memory for the pages. The page reference string is:
123256346373153634243451
The number of page faults in LRU and optimal page replacement algorithms are
respectively (without including initial page faults to fill available page frames with
pages): [NET June 2014]
(A) 9 and 6 (B) 10 and 7 (C) 9 and 7 (D) 10 and 6

Q.9 In a demand paging memory system, page table is held in registers. The time taken to
service a page fault is 8m.sec. if an empty frame is available or if the replaced page is not
modified, and it takes 20 m. secs., if the replaced page is modified. What is the average
access time to service a page fault assuming that the page to be replaced is modified 70%
of the time? [NET Dec. 2014]
(A) 11.6 m.sec. (B) 16.4 m.sec. (C) 28 m.sec. (D) 14 m.sec

Q.10 A LRU page replacement is used with 4 page frames and eight pages. How many page
faults will occur with the reference string 0172327103 if the four frames are initially
empty? [NET June 2015]
(A) 6 (B) 7 (C) 5 (D) 8

Q.11 A virtual memory has a page size of 1K words. There are eight pages and four blocks.
The associative memory page table contains the following entries:

Page Block
0 3
2 1
5 2
7 0

Which of the following list of virtual addresses (in decimal) will not cause any page fault
if referenced by the CPU? [NET Dec. 2015]
(A) 1024, 3072, 4096, 6144 (B) 1234, 4012, 5000, 6200
(C) 1020, 3012, 6120, 8100 (D) 2021, 4050, 5112, 7100

Q.12 Suppose that the number of instructions executed between page fault is directly
proportional to the number of page frames allocated to a program. If the available
memory is doubled, the mean interval between the page faults is also doubled. Further,
consider that a normal instruction takes one microsecond, but if a page fault occurs, it
takes 2001 microseconds. If a program takes 60 sec to run, during which time it gets
15,000 page faults, how long would it take to run twice as much memory were available?
[NET Dec. 2015]
(A) 60 sec (B) 30 sec (C) 45 sec (D) 10 sec

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[33]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.13 Consider the reference string: [NET July 2016]


012301401234
If FIFO page replacement algorithm is used, then the number of page faults with three
page frames and four page frames are ____ and ___ respectively.
(A) 10, 9 (B) 9, 9 (C) 10, 10 (D) 9, 10

Q.14 Which of the following is incorrect for virtual memory? [NET Jan. 2017]
(A) Large programs can be written
(B) More I/O is required
(C) More addressable memory available
(D) Faster and easy swapping of process

Q.15 Consider a virtual page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1


Suppose a demand paged virtual memory system running on a computer system such that
the main memory has 3 page frames. Then __________ page replacement algorithm has
minimum number of page faults. [NET Nov. 2017]
(A) FIFO (B) LIFO (C) LRU (D) Optimal

Q.16 Consider a virtual page reference string 1, 2, 3, 2, 4, 2, 5, 2, 3, 4. Suppose LRU page


replacement algorithm is implemented with 3 page frames in main memory. Then the
number of page faults are _____. [NET July 2018]
(A) 5 (B) 7 (C) 9 (D) 10

ANSWER KEY
1. (C) 2. (A) 3. (A) 4. (C) 5. (C) 6. (C)
7. (B) 8. (B) 9. (B) 10. (B) 11. (C) 12. (C)
13. (D) 14. (B) 15. (D) 16. (B)

SOLUTION
Sol.1

Hence, Option (c) 10 page fault.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[34]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.2 A is the best answer here.


Virtual memory provides
1. increased address space for processes
2. memory protection
3. relocation
So, when we don't need more address space, even if we get rid of virtual memory, we
need hardware support for the other two. Without hardware support for memory
protection and relocation, we can design a system (by either doing them in software or by
partitioning the memory for different users) but those are highly inefficient mechanisms.
i.e., there we have to divide the physical memory equally among all users and this limits
the memory usage per user and also restricts the maximum number of users.

1
Sol.3 Page fault rate =
k
1
Page hit rate = 1 −
k
Service time = i
Page fault service time = i + j
Effective memory access time,
1  1 (i  j) i
=  (i  j)  1    i = i
k  k k k
i j i j
=  i = i
k k k k
So, option (A) is correct.

Sol.4 Ans. is C
Medium term scheduling is part of the swapping. It removes the processes from the
memory. It reduces the degree of multiprogramming.
Long term scheduler determines which programs are admitted to the system
for processing. Job scheduler selects processes from the queue and loads them into
memory for execution. Process loads into the memory for CPU scheduling.
Short-term scheduler (or CPU scheduler) – selects which process should be executed
next and allocates CPU.
mutual exclusion has nothing to do here

Sol.5 Let P be the page fault rate


Effective Memory Access Time = p * (page fault service time) + (1 – p) * (Memory
access time)
= (1 / (10 ^ 6)) * 10 * (10 ^ 6) ns + (1 – 1 / (10 ^ 6)) * 20 ns
= 30 ns (approx)

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[35]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.6 ans. C
9 and 8
FIFO replacement: Replace the oldest page. (page with oldest load time).
ABACABDBACD // marked pages cause fault
BACABDBACD // marked pages cause fault

Sol.7 Principal of Locality


The "working set" can be referred as "parts of memory that the current algorithm is
using" and is determined by which parts of memory the CPU just happens to access. If
you are processing an array and storing the results in a table, the array and the table are
your working set in this context.
This is discussed because the CPU will automatically store accessed memory in cache,
close to the processor. The working set is a nice way to describe the memory you want
stored. If it is small enough, it can all fit in the cache and your algorithm will run very
fast.
Or in other words we can say
The "working set" is an informal term meaning the memory that's being accessed
"frequently" by an application or set of applications.
Principal of Locality does the same thing as explained above.
There are 2 types of Locality of reference, that particular element will be present in a
close proximity around the one which we have previously referred
2. Temporal locality: it says least recently used element is going to be used again .

Sol.8 LRU Page Replacement:-

Number of Page Fault = 10


Optimal Page Replacement:-
Number of Page Fault = 7

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[36]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Hence, Option (B) 10 and 7 is the correct choice.

Sol.9 Service a page fault = 8msec.


Page is not modified = 20m.sec.
Page replace = 70% of time
the average access time to service a page fault = 0.7 ⨉ 20 + 0.3 ⨉ 8 = 14 + 2.4 = 16.4ms

Sol.10

1 2 3 4 5 hit hit hit 6 7

0 0 0 0 3 3 3 3 0 0
1 1 1 1 1 1 1 1 1
7 7 7 7 7 7 7 7
2 2 2 2 2 2 3

Total page fault = 7

Sol.11 Since page size is 1k =1024 words so


address range ( Page number)
0-1023 (0)
1024- 2047 (1)
2048- 3071 (2)
3072- 4095 (3)
4096- 5119 (4)
5120- 6143 (5)
6144- 7167 (6)
7168- 8191 (7)
by using above we can make string from given virtual addresses
pages already in memory are 0,2,5,7 now for no page fault to occur string must be
0,2,5,7
choice a will produce string 1,3,4,6 so page fault will occur
choice b will produce string 1,3,4,6 so page fault will occur
choice d will produce string 1,3,4,6 so page fault will occur
choice C will will produce string 0, 2, 5, 7 hence no page fault so ans. is C
Sol.12 ans. should be C 45 sec
Normal instruction takes 1 micro second 10^-6 sec
instruction with page fault takes 2001 micro seconds so p.f take 2000 microsecond
now given program takes 60 sec and there were 15000 p.f
so time taken by page faults= 15000x2000 micro seconds=30 sec
rest 30 sec are consumed by program execution
if memory is doubled than the mean interval between the page faults is also doubled(and

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[37]
OPERATING SYSTEM GATE-PSUs-UGC-NET

hence p.f rate will be reduced by half) so when earlier 30 sec were needed by program
instructions and 30 sec of p.f
now program execution takes 30 sec and p.f will take 15 sec(15000x2000x10^-3)/2
so total time =30+15 =45 sec

Sol.13 For frame size = 3


012301401234
FFFFFFFHHFFH
Total 9 page fault
For Frame Size = 4
012301401234
FFFFHHFFFFFF
Total 10 page fault
So option D is Ans.

Sol.14 option (B) is correct.


1. We can write large program when we have memory extension.
2. Less I/O requirement in case of virtual memory.
3. More addressable memory available with virtual memory
4. Faster and easy swapping of process with the help of page replacement policy in
virtual memory

Sol.15

1. In FIFO algorithm 15 page fault will occur.

2. In LIFO algorithm 11 page fault will occur.

3. In LRU algorithm 12 page fault will occur.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[38]
OPERATING SYSTEM GATE-PSUs-UGC-NET

4. In optimal algorithm 9 page fault will occur.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[39]
OPERATING SYSTEM GATE-PSUs-UGC-NET

FILE MANAGEMENT
Q.1 A UNIX file system has 1 KB block size and 4-byte disk addresses. What is the
maximum file size if the inode contains ten direct block entries, one single indirect block
entry, one double indirect block entry and one triple indirect block entry?
[NET June 2013]
(A) 30 GB (B) 64 GB (C) 16 GB (D) 1 GB

Q.2 The versions of windows operating system like Windows XP and Window Vista uses
following file system: [NET June 2013]
(A) FAT-16 (B) FAT-32
(C) NTFS (NT File System) (D) All of the above

Q.3 The directory structure used in Unix file system is called [NET Dec. 2013]
(A) Hierarchical directory (C) Tree structured directory
(C) Directed acrylic graph (D) Graph structured directory

Q.4 Match the following: [NET June 2014]


List – I List – II
a. Contiguous allocation i. This scheme supports very large file sizes
b. Linked allocation ii. This allocation technique supports only sequential
files
c. Indexed allocation iii. Number of disks required to access file is minimal
d. Multi-level indexed iv. This technique suffers from maximum wastage of
space in storing pointers
(A) a–iii; b–iv; c–ii; d–i (B) a–iii; b–ii; c–iv; d–i
(C) a–i; b–ii; c–iv; d–iii (D) a–i; b–iv; c–ii; d–iii

Q.5 __________ maintains the list of free disk blocks in the Unix file system.
(A) I-node (B) Boot block [NET June 2014]
(C) Super block (D) File allocation table

Q.6 In the index allocation scheme of blocks to a file, the maximum possible size of the file
depends on: [NET June 2015]
(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 these

Q.7 In _____ allocation method for disk block allocation in a file system, insertion and
deletion of blocks in a file is easy [NET June 2015]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[40]
OPERATING SYSTEM GATE-PSUs-UGC-NET

(A) Index (B) Linked (C) Contiguous (D) Bit Map

Q.8 A unix file may be of the type [NET June 2015]


(A) Regular file (B) Directory file
(C) Device file (D) Any one of the above

Q.9 In Unix operating system, special files are used to [NET Dec. 2015]
(A) buffer data received in its input from where a process reads
(B) provide a mechanism to map physical device to file names
(C) store list of file names plus pointers associated with i-nodes
(D) store information entered by a user application program or utility program

Q.10 Match the following in Unix file system: [NET Dec. 2015]
List-I List-II
a. Boot block i. Information about file system
b. Super block ii. Information about file
c. Inode table iii. Storage space
d. Data block iv. Code for making OS ready
(A) a–iv, b–i, c–ii, d–iii (B) a–i, b–iii, c–ii, d–iv
(C) a–iii, b–i, c–ii, d–iv (D) a–iv, b–ii, c–i, d–iii

ANSWER KEY
1. (C) 2. (D) 3. (C) 4. (B) 5. (C) 6. (B)
7. (B) 8. (D) 9. (B) 10. (A)

SOLUTION
Sol.1 Disk block size = 1KB
Disk block address = 4B
Maximum file size possible = (DB size/DBA)3 * DB size
= (1KB/4B)3 * 1KB
= 16GB

Sol.2 D
FAT16 is the original file system used in DOS and Windows 3.x, and was originally only
designed for use on relatively small partitions.
FAT32 is a revised version of FAT16 that can be used to create much larger partitions
and has native support for long filenames, and was introduced with Win98.
NTFS, which was introduced with Windows NT, is much more secure and robust than
FAT16 or FAT32, and offers better recovery from errors. NTFS is now offered on
Windows 2000, Windows XP and Windows 2003 Server, although all of the above

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[41]
OPERATING SYSTEM GATE-PSUs-UGC-NET

OS's can also use FAT16 or FAT32. It's generally recommended that NTFS be used
except when backwards compatibility is urgently needed.

Sol.3 It should be C directed acyclic graph


Unix file system directory structure is a DAG due to the presence of hardlinks which
makes sharing of files and subdirectories among different directories possible.

Sol.4 Answer is (B).


Contiguous allocation ---> Number of disks required to access file is minimal.
Linked allocation ---> This allocation technique supports only sequential files
Indexed allocation ---> This technique suffers from maximum wastage of space
Multi-level indexed ---> This scheme supports very large file sizes

Sol.5 A super block describes the state of the file system: the total size of the partition, the
block size, pointers to a list of free blocks, the inode number of the root directory, magic
number, etc.
Hence, Option (C) Super Block.

Sol.6 In the index allocation method, an index block stores the address of all the blocks
allocated to a file.
When indexes are created, the maximum number of blocks given to a file depends upon
the size of the index which tells how many blocks can be there and size of each block(i.e.
same as depending upon the number of blocks for storing the indexes and size of each
index block).
Thus, option (B) is correct.

Sol.7 In linked allocation method for disk block allocation in a file system, insertion and
deletion of blocks in a file is easy.
Option (B) is correct.

Sol.8 A unix file may be of any of the type mentioned in the options

Sol.9 Answer B
 provides a mechanism to map physical device to file names
 Windows and DOS also have special files.
 provide simple interfaces between drivers and peripheral devices such as printers
and serial ports

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[42]
OPERATING SYSTEM GATE-PSUs-UGC-NET

I/O MANAGEMENT
Q.1 On a disk with 1000 cylinders (0 to 999) find the number of tracks, the disk arm must
move to satisfy all the requests in the disk queue. Assume the last request service was at
track 345 and the head is moving toward track 0. The queue in FIFO order contains
requests for the following tracks: 123, 874, 692, 475, 105, 376 (Assume scan algorithm)
[NET June 2012]
(A) 2013 (B) 1219 (C) 1967 (D) 1507

Q.2 If the disk head is located initially at 32, find the number of disk moves required with
FCFS if the disk queue of I/O blocks requests are 98. 37, 14, 124, 65, 67.
[NET June 2013]
(A) 239 (B) 310 (C) 321 (D) 325

Q.3 Match the following: [NET June 2013]


a. RAID 0 i. Bit interleaved parity
b. RAID 1 ii. Non redundant stripping
c. RAID 2 iii. Mirrored disks
d. RAID 3 iv. Error correcting codes
(A) a–iv, b–i, c–ii, d–iii (B) a–iii, b–iv, c–i, d–ii
(C) a–iii, b–i, c–iv, d–ii (D) a–iii, b–ii, c–iv, d–i

Q.4 Consider a disk queue with request for input/output to block cylinders 98, 183, 37, 122,
14, 124, 65, 67 in that order. Assume that disk head is initially positioned at cylinder 53
and moving towards cylinder number 0. The total number of head movements using
Shortest Seek Time First (SSTF) and SCAN algorithms are respectively
[NET Dec. 2013]
(A) 236 and 252 cylinders (B) 640 and 236 cylinders
(C) 235 and 640 cylinders (D) 235 and 252 cylinders

Q.5 How much space will be required to store the bit map of a 1.3 GB disk with 512 bytes
block size? [NET Dec. 2013]
(A) 332.8 KB (B) 83.6 KB (C) 266.2 KB (D) 256.6 KB

Q.6 Which one of the following statements is not true about disk-arm scheduling algorithms?
(A) SSTF (shortest seek time first) algorithm increases performance of FCFS.
(B) The number of requests for disk service are not influenced by file allocation method.
(C) Caching the directories and index blocks in main memory can also help in reducing
disk arm movements.
(D) SCAN and C-SCAN algorithms are less likely to have a starvation problem.
[NET June 2014]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[43]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.7 Various storage devices used by an operating system can be arranged as follows in
increasing order of accessing speed: [NET Dec. 2014]
(A) Magnetic tapes → magnetic disks → optical disks → electronic disks → main
memory → cache →registers
(B) Magnetic tapes → magnetic disks → electronic disks → optical disks → main
memory → cache →registers
(C) Magnetic tapes → electronic disks → magnetic disks → optical disks → main
memory → cache →registers
(D) Magnetic tapes → optical disks → magnetic disks → electronic disks → main
memory → cache →registers

Q.8 How many disk blocks are required to keep list of free disk blocks in a 16 GB hard disk
with 1kB block size using linked list of free disk blocks? Assume that the disk block
number is stored in 32 bits. [NET Dec. 2014]
(A) 1024 blocks (B) 16794 blocks (C) 20000 blocks (D) None of these

Q.9 Consider an imaginary disk with 40 cylinders. A request come to read a block on
cylinder 11. While the seek to cylinder 11 is in progress, new requests come in for
cylinders 1, 36, 16, 34, 9 and 12 in that order. The number of arm motions using shortest
seek first algorithm is [NET Dec. 2014]
(A) 111 (B) 112 (C) 60 (D) 61

Q.10 A disk drive has 100 cylinders, numbered 0 to 99. Disk requests come to the disk driver
for cylinders 12, 26, 24, 4, 42, 8 and 50 in that order. The driver is currently serving a
request at a cylinder 24. A seek takes 6 msec per cylinder moved. How much seek time is
needed for shortest seek time first (SSTF) algorithm? [NET June 2015]
(A) 0.984 sec (B) 0.396 sec (C) 0.738 sec (D) 0.42 sec

Q.11 Consider a disk with 16384 bytes per track having a rotation time of 16 msec and average
seek time of 40 msec. What is the time in msec to read a block of 1024 bytes from this
disk? [NET Dec. 2015]
(C) 57 msec (B) 49 msec (C) 48 msec (D) 17 msec

Q.12 If the Disk head is located initially at track 32, find the number of disk moves required
with FCFS scheduling criteria if the disk queue of I/O blocks requests are 98, 37, 14,
124, 65, 67 [NET July 2016]
(A) 320 (B) 322 (C) 321 (D) 319

Q.13 Consider a disk queue with I/O requests on the following cylinders in their arriving
order: [NET Jan. 2017]
6, 10, 12, 54, 97, 73, 128, 15, 44, 110, 34, 45
The disk head is assumed to be at cylinder 23 and moving in the direction of decreasing
number of cylinders. Total number of cylinders in the disk is 150. The disk head

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[44]
OPERATING SYSTEM GATE-PSUs-UGC-NET

movement using SCAN-scheduling algorithm is:


(A) 172 (B) 173 (C) 227 (D) 228

Q.14 In __________ disk scheduling algorithm, the disk head moves from one end to other
end of the disk, serving the requests along the way. When the head reaches the other end,
it immediately returns to the beginning of the disk without serving any requests on the
return trip. [NET Nov. 2017]
(A) LOOK (B) SCAN (C) C-LOOK (D) C-SCAN

Q.15 Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 37, 122, 14,
124, 65, 67. Suppose SSTF disk scheduling algorithm implemented to meet the requests
then the total number of head movements are __________ if the disk head is initially at
53. [NET Nov. 2017]
(A) 224 (B) 248 (C) 236 (D) 240

ANSWER KEY
1. (B) 2. (C) 3. (*) 4. (*) 5. (A) 6. (B)
7. (D) 8. (D) 9. (D) 10. (D) 11. (B) 12. (C)
13. (*) 14. (D) 15. (C)

SOLUTION
Sol.1 ANS IS OPTION B .1219
345----123(222)-----105(18)-----0(105) 376(376)-----475(99)----692(217)-----874(182)
( ) VALUES ARE THE DISTANCES
SO TOTAL ARM MOVE = 222 + 18 + 105 + 376 + 99 + 217 + 182 = 1219

Sol.2 Acc. to FCFS algorithm, Total disk moves = (98 – 32) + (98 – 37) + (37 – 14) + (124 –
14) + (124 – 65) + (67 – 65) = 321
Ans. C. 321

Sol.3 Explanation:-

The following are the one liners explaining different RAIDs and their specification.
RAID 0 - It has no redundancy.It is JBOD(Just a Bunch of Disks)
RAID 1 - Mirroring or shadowing
RAID 2 - Applying memory-style error correcting codes to disks
RAID 3 - Bit interleaved parity.
So, a - ii, b-iii, c-iv, d-i. These are the correct matches. There is no answer which
matches this. So, the answer is none of the options are right.

Sol.4 all options are incorrect marks to all


correct ans. will be 236 and 236

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[45]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Acc to SCAN 53 to 37 then to 14 and then to 0 (16 + 23 + 14 = 53) now direction will
be reversed so 0 o 65 then to 67 then to 98, 122, 124, 183 (65 + 2 + 31 + 24 + 2 + 59
= 183) total head movements = 183 + 53 = 236
Acc to SSTF 53 to 65 then to 67 then 37, 14, 98, 122, 124, 183 (so head movement
= 12 + 2 + 30 + 23 + 84 + 24 + 2 + 59 = 236)

Sol.5 We need a bit for each block. Number of blocks = disk size/ block size
= 1.3 GB / 512 B
This will give the size of bit map in bits. To get the byte size divide by 8 and we get
332.8 KB. For disk size, GB is taken as 1024*1024*1024 bytes and for KB it is 1024
bytes.

Sol.6 Ans. is B
A) is true as SSTF is optimal
B) is NOT CORRECT as the number of requests for disk service can be greatly
influenced by file allocation method e.g. a program reading contiguous allocated file will
generate several requests that are closed together on the disk hence minimal head
movement . on the other hand linked file or indexed file may include scattered block
which need more head movement
C) is TRUE Caching the directories and index blocks in main memory can also help in
reducing disk arm movements especially for read operation.
d) is TRUE as SCAN & C-SCAN are less likely to be suffer from starvation as they
move in both direction irrespective of type of request. SSTF may suffer from starvation

Sol.7 The storage hierarchy is a ranking of storage devices based on several factors: access
speed, capacity, cost per bit, and volatility.
 registers - fastest access, highest cost/bit, low capacity, volatile
 main memory - slower access than registers (faster than disks), lower cost/bit than
registers (higher than disks), higher capacity than registers (lower than disks),
volatile
 electronic disks - a.k.a. flash memory. slower access than main memory (faster than
hard drives), lower cost/bit than main memory (higher than hard drives), higher
capacity than main memory (lower than hard drives), non-volatile
 magnetic disks - slower access than flash memory (faster than tapes), lower cost/bit
than flash memory (higher than tapes), higher capacity than flash memory (lower
than tapes), nonvolatile
In general, it's faster and easier to write data to magnetic storage media as compared to
on optical media.

Sol.8 no. of disk blocks possible = 16GB/ 1KB = 16M disk blocks available
no. of disk block address possible to store in 1 disk block = 1kB/32bits = 256 address
can be stored in 1 disk block

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[46]
OPERATING SYSTEM GATE-PSUs-UGC-NET

256 disk block address----------------> 1 disk block


16M disk block address-----------------> x
x = 16M/256 = 65536...
NONE OF THE ABOVE

Sol.9 11 – 12 – 9 – 16 – 1 – 34 – 36 sequence of access.


So 1 + 3 + 7 + 15 + 33 + 2 = 61

Sol.10 12, 26, 24, 4, 42, 8 and 50


24 – 26 – 12 – 8 – 4 – 42 – 50 sequence of access
Total (2 + 14 + 4 + 4 + 38 + 8) * 6ms = (70 * 6 / 1000)sec
= 420/1000 = 0.42sec

Sol.11 Transfer time = ((1024 bytes *16 ms) / (16384 bytes)) = 1 msec
Rotational letency = 16 msec / 2 = 8 msec
total time = seek + rotational letency + transfer time
= 40 + 8 + 1 = 49 msec
B is answer

Sol.12 (98 – 32) + (98 – 37) + (37 – 14) + (124 – 14) + (124 – 65) + (67 – 65)
= 66 + 61 + 23 + 110 + 59 + 2
= 321

Sol.13 According to SCAN disk scheduling algorithm:

sequence from input, it


So, total disk head movement = 23+128 = 151.
So, none option matches.

Sol.14 ANSWER is D. In Circular scan head moves in one direction and servers request on its
way, when it reaches to other end of the disk, it returns to the beginning of the disk
without serving any requests on the return trip.

Sol.15

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[47]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Now add all seek time:


12 + 2 + 30 + 23 + 84 + 24 + 2 + 59 = 236
So, option (C) is correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[48]
OPERATING SYSTEM GATE-PSUs-UGC-NET

SECURITY
Q.1 A Trojan horse is [NET Dec. 2014]
(A) A program that performs a legitimate function that is known to an operating system
or its user and also has a hidden component that can be used for nefarious purposes
like attacks on message security or impersonation.
(B) A piece of code that can attach itself to other programs in the system and spread to
other systems when programs are copied or transferred.
(C) A program that spreads to other computer systems by exploiting security holes like
weaknesses in facilities for creation of remote processes
(D) All of the above

ANSWER KEY
1. (A)

SOLUTION
Sol.1 Trojans
A Trojan is another type of malware named after the wooden horse the Greeks used to
infiltrate Troy. It is a harmful piece of software that looks legitimate. Users are typically
tricked into loading and executing it on their systems. After it is activated, it can achieve
any number of attacks on the host, from irritating the user (popping up windows or
changing desktops) to damaging the host (deleting files, stealing data, or activating and
spreading other malware, such as viruses). Trojans are also known to create back doors to
give malicious users access to the system.
Unlike viruses and worms, Trojans do not reproduce by infecting other files nor do they
self-replicate. Trojans must spread through user interaction such as opening an e-mail
attachment or downloading and running a file from the Internet.
Hence, ans. is A

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[49]
OPERATING SYSTEM GATE-PSUs-UGC-NET

MISCELLANEOUS
Q.1 Match the following w.r.t. Input/Output management: [NET Jan. 2017]
List-I List-II
a. Device controller i. Extracts information from the controller register and
store it in data buffer
b. Device driver ii. I/O scheduling
c. Interrupt handler iii. Performs data transfer
d. Kernel I/O subsystem iv. Processing of I/O request
(A) a–iii; b–iv; c–i; d–ii (B) a–ii; b–i; c–iv; d–iii
(C) a–iv; b–i; c–ii; d–iii (D) a–i; b–iii; c–iv; d–ii

ANSWER KEY
1. (D)

SOLUTION
Sol.1 option 4.
a. Device controller i. Extracts information from the controller register and
store it in data buffer
b. Device driver iii. Performs data transfer
c. Interrupt handler iv. Processing of I/O request
d. Kernel I/O subsystem ii. I/O scheduling

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[50]
OPERATING SYSTEM GATE-PSUs-UGC-NET

DEADLOCKS, PROCESS SYNCHRONIZATION & CPU SCHEDULING


Q.1 An operating system uses the Banker’s algorithm for deadlock avoidance when
managing the allocation of three resource types X, Y, and Z to three processes P0, P1,
and P2. The table given below presents the current system state. Here, the Allocation
matrix shows the current number of resources of each type allocated to each process and
the Max matrix shows the maximum number of resources of each type required by each
process during its execution.

There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The
system is currently in a safe state. Consider the following independent requests for
additional resources in the
current state: [GATE 2014]
REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z
REQ2: P1 requests 2 units of X, 0 units of Y and 0 units of Z
Which one of the following is TRUE?
(A) Only REQ1 can be permitted.
(B) Only REQ2 can be permitted.
(C) Both REQ1 and REQ2 can be permitted.
(D) Neither REQ1 nor REQ2 can be permitted

Q.2 A system contains three programs and each requires three tape units for its operation. The
minimum number of tape units which the system must have such that deadlocks never
arise is _________. [GATE 2014]

Q.3 A system has 6 identical resources and N processes competing for them. Each process
can request at most 2 requests. Which one of the following values of N could lead to a
deadlock? [GATE 2014]
(A) 1 (B) 2 (C) 3 (D) 4

Q.4 Consider the following policies for preventing deadlock in a system with mutually
exclusive resources. [GATE 2015]
I. Processes should acquire all their resources at the beginning of execution. If any
resource is not available, all resources acquired so far are released.
II. The resources are numbered uniquely, and processes are allowed to request for
resources only in increasing resource numbers.
III. The resources are numbered uniquely, and processes are allowed to request for
resources only in decreasing resource numbers.
IV. The resources are numbered uniquely. A process is allowed request only for a
resource with resource number larger than its currently held resources.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[51]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Which of the above policies can be used for preventing deadlock?


(A) Any one of I and III but not II or IV (B) Any one of I, III and IV but not II
(C) Any one of II and III but not I or IV (D) Any one of I, II, III and IV

Q.5 Match the pairs in the following questions: [GATE 1990]


(a) Critical region (p) Hoare's monitor
(b) Wait/Signal (q) Mutual exclusion
(c) Working Set (r) Principle of locality
(d) Deadlock (s) Circular Wait

Q.6 Consider the following proposed solution for the critical section problem. There
are n processes P0....Pn−1. In the code, function pmax returns an integer not smaller than
any of its arguments .For all i, t[i] is initialized to zero. [GATE 2016]
Code for Pi;
do {
c[i] = 1; t[i] = pmax (t[0],....,t[n – 1]) + 1; c[i] = 0;
for every j != i in {0,....,n – 1}
{ while (c[j]);
while (t[j]! = 0 && t[j] <= t[i]); }
Critical Section; t[i] = 0;
Remainder Section; } while (true);
Which of the following is TRUE about the above solution?
(A) At most one process can be in the critical section at any time
(B) The bounded wait condition is satisfied
(C) The progress condition is satisfied
(D) It cannot cause a deadlock

Q.7 Consider the following two-process synchronization solution. [GATE 2016]


Process 0 Process 1
Entry: loop while (turn == 1); Entry: loop while (turn == 0);
(critical section) (critical section)
Exit: turn = 1; Exit turn = 0;
The shared variable turn is initialized to zero. Which one of the following is TRUE?
(A) This is a correct two-process synchronization solution.
(B) This solution violates mutual exclusion requirement.
(C) This solution violates progress requirement.
(D) This solution violates bounded wait requirement.

Q.8 Consider a non-negative counting semaphore S. The operation P(S) decrements S, and
V(S) increments S. During an execution, 20 P(S) operations and 12 V(S) operations are

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[52]
OPERATING SYSTEM GATE-PSUs-UGC-NET

issued in some order. The largest initial value of S for which at least one P(S) operation
will remain blocked is ________. [GATE 2016]

Q.9 Consider the set of process with arrival time (in milliseconds), CPU burst time (in
milliseconds) and priority (0 is the highest priority) shown below . None of the process
have I/O burst time [GATE 2017]
Process Arrival Time Burst Time Priority
P1 0 11 2
P2 5 28 0
P3 12 2 3
P4 2 10 1
P5 9 16 4
The average waiting time (in milliseconds) of all the process using premtive priority
scheduling algorithm is ______

Q.10 A system shares 9 tape drives. The current allocation and maximum requirement of tape
drives for 3 processes are shown below: [GATE 2017]

Which of the following best describes the current state of the system?
(A) Safe, Deadlocked (B) Safe, Not Deadlocked
(C) Not Safe, Deadlocked (D) Not Safe, Not Deadlocked

Q.11 Consider the following CPU processes with arrival times (in milliseconds) and length of
CPU bursts (in milliseconds) as given below: [GATE 2017]
Process Arrival Time Burst Time
P1 0 7
P2 3 3
P3 5 5
P4 6 2
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule
the processes, then the average waiting time across all processes is ______milliseconds.

Q.12 Consider a system with 3 processes that share 4 instances of the same resource type.
Each process can request a maximum of K instances. Resource instances can be
requested and released only one at a time. The largest value of K that will always avoid
deadlock is _________. [GATE 2018]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[53]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.13 In a system, there are three types of resources: E, F and G. Four processes P0, P1, P2 and
P3 execute concurrently. At the outset, the processes have declared their maximum
resource requirements using a matrix named Max as given below. For example, Max[P2,
F] is the maximum number of instances of F that P2 would require. The number of
instances of the resources allocated to the various processes at any given state is given by
a matrix named Allocation.
Consider a state of the system with the Allocation matrix as shown below, and in which 3
instances of E and 3 instances of F are the only resources available. [GATE 2018]

From the perspective of deadlock avoidance, which one of the following is true?
(A) The system is in safe state
(B) The system is not in safe state, but would be safe if one more instance of E were
available
(C) The system is not in safe state, but would be safe if one more instance of F were
available
(D) The system is not in safe state, but would be safe if one more instance of G were
available

Q.14 Consider the following solution to the producer-consumer synchronization problem. The
shared buffer size is N. Three semaphores empty, full and mutex are defined with
respective initial values of 0, N and 1. Semaphore empty denotes the number of available
slots in the buffer, for the consumer to read from. Semaphore full denotes the number of
available slots in the buffer, for the producer to write to. The placeholder variables,
denoted by P, Q, R and S, in the code below can be assigned either empty or full. The
valid semaphore operations are: wait() and sigmal(). [GATE 2018]
Producer: Consumer:
do { do {
wait (P); wait (R);
wait (mutex); wait (mutex);
//Add item to buffer //consume item from buffer
signal (mutex); signal (mutex);
signal (Q); signal(S);
}while(1); }while(1)
Which one of the following assignments to P, Q, R and S will yield the correct solution?
(A) P: full, Q: full, R: empty, S: empty (B) P: empty, Q: empty, R: full, S: full
(C) P: full, Q: empty, R: empty, S: full (D) P: empty, Q: full, R: full, S: empty

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[54]
OPERATING SYSTEM GATE-PSUs-UGC-NET

ANSWER KEY
1. (B) 2. (7) 3. (*) 4. (D) 5. (*) 6. (A)
7. (C) 8. (7) 9. (29) 10. (B) 11. (3) 12. (2)
13. (A) 14. (C)
SOLUTION
Sol.1 This is the current safe state.
AVAILABLE X=3, Y=2, Z=2
MAX ALLOCATION
XYZ XYZ
P0 843 001
P1 620 320
P2 333 211
Now, if the request REQ1 is permitted, the state would become:
AVAILABLE X=3, Y=2, Z=0
MAX ALLOCATION NEED
XYZ XYZ XYZ
P0 843 003 840
P1 620 320 300
P2 333 211 122
Now, with the current availability, we can service the need of P1. The state would
become:
AVAILABLE X=6, Y=4, Z=0
MAX ALLOCATION NEED
XYZ XYZ XYZ
P0 843 003 840
P1 620 320 000
P2 333 211 122
With the resulting availability, it would not be possible to service the need of either P0 or
P2, owing to lack of Z resource.
Therefore, the system would be in a deadlock.
⇒ We cannot permit REQ1.
Now, at the given safe state, if we accept REQ2:
AVAILABLE X=1, Y=2, Z=2
MAX ALLOCATION NEED
With this
XYZ XYZ XYZ
availability, we service P1
P0 843 001 842
(P2 can also be serviced). So,
P1 620 520 100
the state is:
P2 333 211 122
AVAILABLE X=6, Y=4, Z=2

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[55]
OPERATING SYSTEM GATE-PSUs-UGC-NET

MAX ALLOCATION NEED


XYZ XYZ XYZ
P0 843 001 842
P1 620 520 000
P2 333 211 122

With the current availability, we service P2. The state becomes:


AVAILABLE X=8, Y=5, Z=3
MAX ALLOCATION NEED
XYZ XYZ XYZ
P0 843 001 842
P1 620 520 000
P2 333 211 000
Finally, we service P0. The state now becomes:
AVAILABLE X=8, Y=5, Z=4
MAX ALLOCATION NEED
XYZ XYZ XYZ
P0 843 001 000
P1 620 520 000
P2 333 211 000

The state so obtained is a safe state. ⇒ REQ2 can be permitted.


So, only REQ2 can be permitted.
Hence, B is the correct choice.

Sol.2 If 6 resources are there then it may be possible that all three process have 2 resources
and waiting for 1 more resource. Therefore, all of them will have to wait indefinitely. If 7
resources are there, then atleast one must have 3 resources so deadlock can never occur.

Sol.3 It seems to be wrong question in GATE exam. Below seems to be the worst case
situation. In below situation P1 and P2 can continue as they have 2 resources each
P1 --> 2 P2 --> 2 P3 --> 1 P4 --> 1

Sol.4 If Ist is followed, then hold and wait will never happen.
II, III and IV are similar. If any of these is followed, cyclic wait will not be possible.

Sol.6 Mutual exclusion is satisfied:


All other processes j started before i must have value (i.e. t[j]) less than the value of
process i (i.e. t[i]) as function pMax() return a integer not smaller than any of its
arguments. So if anyone out of the processes j have positive value will be executing in

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[56]
OPERATING SYSTEM GATE-PSUs-UGC-NET

its critical section as long as the condition t[j] > 0 && t[j] <= t[i] within while will
persist. And when this j process comes out of its critical section, it sets t[j] = 0; and next
process will be selected in for loop. So when i process reaches to its critical section none
of the processes j which started earlier before process i is in its critical section. This
ensure that only one process is executing its critical section at a time.
Deadlock and progress are not satisfied:
while (t[j] != 0 && t[j] <=t[i]); because of this condition deadlock is possible when value
of j process becomes equals to the value of process i (i.e t[j] == t[i]). because of the
deadlock progress is also not possible (i.e. Progress == no deadlock) as no one process is
able to make progress by stopping other process.
Bounded waiting is also not satisfied:
In this case both deadlock and bounded waiting to be arising from the same reason as if
t[j] == t[i] is possible then starvation is possible means infinite waiting.

Sol.7 Explanation: A mutual exclusive requirement prevents simultaneous access to a shared


resource. Since, semaphore turn is initialized to zero and this semaphore value is
changing only after critical section for given processes. So, this ensures at most one
process in the critical section at a time, i.e., mutual exclusive requirement is satisfied.
Progress means that process should eventually be able to complete. But directly Process
1 cannot go critical section as semaphore value is 0 initially and this process 1 can go CS
only after process 0. So, progress requirement is not satisfied.
Bounded waiting means no process should wait for a resource for infinite amount of
time. Process 1 can go directly and Process 1 can go after process 0 into critical section.
So, Bounded waiting is satisfied.
Option (C) is correct.

Sol.8 The negative value of the counting semaphore indicates the number of processes in the
suspended list (or blocked). e.g. s =−2 means 2 processes in the suspended list or
blocked list.
Here mentioned in the question at least one P(S) operation remain in the blocked state,
therefore, it will −1.
So, x – 20 + 12 = −1
x – 8 = −1
x=7

Sol.9 Gantt Chart for above problem looks like:

Waiting Time = Completion time − Arrival time − Burst Time


∑ AT = 0 + 5 + 12 + 2 + 9 = 28
∑ BT = 11 + 28 + 2 + 10 + 16 = 67
∑ CT = 67 + 51 + 49 + 40 + 33 = 240

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[57]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Waiting time = 240 – 28 – 67 = 145


145
Average Waiting Time = = 29 msec.
5

Sol.10
Process Current Allocation Max Requirements Need
P1 3 7 4
P2 1 6 5
P3 3 5 2
Given there are total 9 tape drives,
so, according to the above table we can see we have currently allocated (7 tape drive),
so currently Available tape drive = 2
So, P3 can use it and after using it will release it 3 resources New Available = 5
then P1 can use it and will release it 3 resources so New Available =8
and lastly P2 so, all the process are in SAFE STATE and there will
be NO DEADLOCK
Safe Sequence will be P3→P2→ P1 or P3→P1→P2.
Answer will be (B) only.

Sol.11

Calculations: Sum of (Complete time – (Arrival Time + Burst Time)) for all processes
i.e. ((17 – 10) + (12 – 7) + (8 – 8) + (6 – 6))/4 = 12/4
= 3 milliseconds.

Sol.12 Given,
Number of processes (P) = 3
Number of resources (R) = 4
Since deadlock-free condition is:
R ≥ P(N − 1) + 1
Where R is total number of resources,
P is the number of processes, and
N is the max need for each resource.
4 ≥ 3(N − 1) + 1

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[58]
OPERATING SYSTEM GATE-PSUs-UGC-NET

3 ≥ 3(N − 1)
1 ≥ (N − 1)
N≤2
Therefore, the largest value of K that will always avoid deadlock is 2.

Sol.13 Explanation:

Available (3, 3, 0), which can satisfy either P0 or P2.


Take P0 <3, 3, 0>. After completion we have (3, 3, 0) + (1, 0, 1) = (4, 3, 1)
Take P2 <0, 3, 0>. After completion we have (4, 3, 1) + (1, 0, 3) = (5, 3, 4)
Take P1 <1, 0, 2>. After completion we have (5, 3, 4) + (1, 1, 2) = (6, 4, 6)
Take P3 <3, 4, 1>. After completion we have (6, 4, 6) + (2, 0, 0) = (8, 4, 6)
Safe sequence : P0–>P2–>P1–>P3
Therefore, option (A) is Correct.

Sol.14 Given,
Empty = 0
Full = N
Mutex = 1
Since value of empty semaphore is 0, so you cannot wait empty semaphore in first
attempt.
Note – empty semaphore denotes the number of filled slots, so producer process must
deal with empty and mutex semaphores. full semaphore denotes the number of empty
slots so consumer process must deal with full and mutex semaphores.
Option (A) causes starvation.
Option (B) causes starvation.
Option (D) since number of filled slots are 0 initially denoted by empty semaphore, so
consumer process cannot consume. So, this implementation is wrong.
Only P: empty, Q: full, R: full, S: empty is correct order to ensure deadlock-free and
starvation free implementation.
Option (C) is correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[59]
OPERATING SYSTEM GATE-PSUs-UGC-NET

MEMORY MANAGEMENT
Link for Question: 1 & 2
A computer uses 46−bit virtual address, 32−bit physical address, and a three–level paged
page table organization. The page table base register stores the base address of the first-
level table (T1), which occupies exactly one page. Each entry of T1 stores the base
address of a page of the second-level table (T2). Each entry of T2 stores the base address
of a page of the third-level table (T3). Each entry of T3 stores a page table entry (PTE).
The PTE is 32 bits in size. The processor used in the computer has a 1 MB 16 way set
associative virtually indexed physically tagged cache. The cache block size is 64 bytes.
Q.1 What is the size of a page in KB in this computer? [GATE 2013]
(A) 2 (B) 4 (C) 8 (D) 16

Q.2 What is the minimum number of page colours needed to guarantee that no two synonyms
map to different sets in the processor cache of this computer? [GATE 2013]
(A) 2 (B) 4 (C) 8 (D) 16

Q.3 Consider a paging hardware with a TLB. Assume that the entire page table and all the
pages are in the physical memory. It takes 10 milliseconds to search the TLB and 80
milliseconds to access the physical memory. If the TLB hit ratio is 0.6, the effective
memory access time (in milliseconds) is _________. [GATE 2014]

Q.4 Consider a system with byte-addressable memory, 32 bit logical addresses, 4 kilobyte
page size and page table entries of 4 bytes each. The size of the page table in the system
in megabytes is ___________ [GATE 2014]
(A) 2 (B) 4 (C) 8 (D) 16

Q.5 A computer system implements a 40 bit virtual address, page size of 8 kilobytes, and a
128-entry translation look-aside buffer (TLB) organized into 32 sets each having four
ways. Assume that the TLB tag does not store any process id. The minimum length of the
TLB tag in bits is _________ [GATE 2015]

Q.6 Consider six memory partitions of size 200 KB, 400 KB, 600 KB, 500 KB, 300 KB, and
250 KB, where KB refers to kilobyte. These partitions need to be allotted to four
processes of sizes 357 KB, 210 KB, 468 KB and 491 KB in that order. If the best fit
algorithm is used, which partitions are NOT allotted to any process?
(A) 200 KB and 300 KB (B) 200 KB and 250 KB
(C) 250 KB and 300 KB (D) 300 KB and 400 KB
[GATE 2015]
Q.7 A Computer system implements 8 kilobyte pages and a 32-bit physical address space.
Each page table entry contains a valid bit, a dirty bit three permission bits, and the
translation. If the maximum size of the page table of a process is 24 megabytes, the
length of the virtual address supported by the system is _______________ bits
[GATE 2015]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[60]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.8 In a file allocation system, which of the following allocation scheme(s) can be used if no
external fragmentation is allowed? [GATE 2017]
I. Contiguous II. Linked III. Indexed
(A) I and III only (B) II only (C) III only (D) II and III only

ANSWER KEY
1. (C) 2. (C) 3. (122) 4. (4MB) 5. (22) 6. (A)
7. (36) 8. (D)
SOLUTION
Sol.1 Let the page size is of 'x' bits
Size of T1 = 2 ^ x bytes
(This is because T1 occupies exactly one page)
Now, number of entries in T1 = (2^x) / 4
(This is because each page table entry is 32 bits or 4 bytes in size)
Number of entries in T1 = Number of second level page tables
(Because each I-level page table entry stores the base address of page of II-level page
table)
Total size of second level page tables = ((2^x) / 4) * (2^x)
Similarly, number of entries in II-level page tables = Number of III level page tables
= ((2^x) / 4) * ((2^x) / 4)
Total size of third level page tables = ((2^x) / 4) * ((2^x) / 4) * (2^x)
Similarly, total number of entries (pages) in all III-level page tables
= ((2^x) / 4) * ((2^x) / 4) * ((2^x) / 4)
= 2^(3x – 6)
Size of virtual memory = 2^46
Number of pages in virtual memory = (2^46) / (2^x) = 2^(46 – x)
Total number the pages in the III-level page tables = Number of pages in virtual memory
2^(3x – 6) = 2^(46 – x)
3x –6 = 46 – x
4x = 52
x = 13
That means, page size is of 13 bits or Page size = 2^13 bytes = 8 KB

Sol.2 Let the page size be x.


2 46
Since virtual address is 46 bits, we have total number of pages =
x
We should have an entry for each page in last level page table which here is T3. So,
2 46
number of entries in T3 (sum of entries across all possible T3 tables) =
x
246 2 48
Each entry takes 32 bits = 4 bytes. So, total size of T3 tables = 4 = bytes
x x
Now, no. of T3 tables will be Total size of T3 tables/page table size and for each of these

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[61]
OPERATING SYSTEM GATE-PSUs-UGC-NET

page tables, we must have a T2 entry. Taking T3 size as page size, no. of entries across
248
248
all T2 tables = x  2
x x
250
48
2 2 250
Now, no. of T2 tables (assuming T2 size as page size) = 2  4 bytes = x  3 .
x x x
Now, for each of these page table, we must have an entry in T1. So, number of entries
250
in T1 =
x3
250 252
And size of T1 =  4 
x3 x3
Given in question, size of T1 is page size which we took as x. So,
252
x= 3
x
x = 252
4

x = 213
= 8KB
Min. no. of page color bits = No. of set index bits + no. of offset bits − no. of page index
bits (This ensures no synonym maps to different sets in the cache)
We have 1MB cache and 64B cache block size. So,
number of sets = 1MB/(64 B × Number of blocks in each set) = 16K/16(16 way set
associative) =1K=210.
So, we need 10 index bits. Now, each block being 64(26) bytes means we need 6 offset
bits.
And we already found page size = 8KB = 213, so 13 bits to index a page
Thus, no. of page color bits = 10 + 6 – 13 = 3.
With 3 page color bits we need to have 23 = 8different page colors

Sol.3 EMAT = TLB hit × (TLB access time + memory access time) + TLB miss(TLB access
time + page table access time + memory access time)
= 0.6(10 + 80) + 0.4(10 + 80 + 80)
= 54 + 68
= 122msec

Sol.4 Number of entries in page table = 232 / 4Kbyte


= 232 / 212
= 20
2
Size of page table = (No. page table entries)*(Size of an entry)
= 220 * 4 bytes
= 222
= 4 Megabytes

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[62]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Sol.5 Total virtual address size = 40


Since there are 32 sets, set offset = 5
Since page size is 8kilobytes, word offset = 13
Minimum tag size = 40 – 5 – 13 = 22

Sol.6 Best fit allocates the smallest block among those that are large enough for the new
process. So the memory blocks are allocated in below order.
357 ---> 400
210 ---> 250
468 ---> 500
491 ---> 600
Sol. the remaining blocks are of 200 KB and 300 KB

Sol.7 Max size of virtual address can be calculated by calculating maximum number of page
table entries. Maximum Number of page table entries can be calculated using given
maximum page table size and size of a page table entry.
Given maximum page table size = 24 MB
Let us calculate size of a page table entry.
A page table entry has following number of bits.
1 (valid bit) + 1 (dirty bit) + 3 (permission bits) + x bits to store physical address space of
a page.
Value of x = (Total bits in physical address) – (Total bits for addressing within a page)
Since size of a page is 8 kilobytes, total bits needed within a page is 13.
So value of x = 32 – 13 = 19
Putting value of x, we get size of a page table entry = 1 + 1 + 3 + 19 = 24bits.
Number of page table entries
= (Page Table Size) / (An entry size)
= (24 megabytes / 24 bits)
= 223
Virtual address Size = (Number of page table entries) * (Page Size)
= 223 * 8 kilobits
= 236
Therefore, length of virtual address space = 36

Sol.8 In contiguous allocation there is always possibility of external fragmentation. Both


indexed and linked allocation are free from external fragmentation.
Therefore, option D

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[63]
OPERATING SYSTEM GATE-PSUs-UGC-NET

VIRTUAL MEMORY
Q.1 Consider the virtual page reference string 1, 2, 3, 2, 4, 1, 3, 2, 4, 1. On a demand paged
virtual memory system running on a computer system that main memory size of 3 pages
frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of
page faults under the corresponding page replacements policy. Then
(A) OPTIMAL < LRU < FIFO (B) OPTIMAL < FIFO < LRU
(C) OPTIMAL = LRU (D) OPTIMAL = FIFO
[GATE 2011]

Q.2 Assume that there are 3 page frames which are initially empty. If the page reference
string is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6 the number of page faults using the optimal
replacement policy is__________. [GATE 2014]

Q.3 A computer has twenty physical page frames which contain pages number 101 through
120. Now a program accesses the pages numbered 1, 2,...,100 in that order, and repeats
the access sequence THRICE. Which one of the following page replacement policies
experiences the same number of page faults as the optimal page replacement policy for
this program? [GATE 2014]
(A) Least-recently-used (B) First-in-first-out
(C) Last-in-first-out (D) Most-recently-used

Q.4 A system uses 3 page frames for storing process pages in main memory. It uses the Least
Recently Used (LRU) page replacement policy. Assume that all the page frames are
initially empty. What is the total number of page faults that will occur while processing
the page reference string given below? [GATE 2014]
4, 7, 6, 1, 7, 6, 1, 2, 7, 2

Q.5 Consider a main memory with five-page frames and the following sequence of page
references: 3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3. Which one of the following is true with
respect to page replacement policies First In First Out (FIFO) and Least Recently Used
(LRU)? [GATE 2015]
(A) Both incur the same number of page faults
(B) FIFO incurs 2 more page faults than LRU
(C) LRU incurs 2 more page faults than FIFO
(D) FIFO incurs 1 more page faults than LRU
Q.6 Consider a computer system with 40-bit virtual addressing and page size of sixteen
kilobytes. If the computer system has a one-level page table per process and each page
table entry requires 48 bits, then the size of the per-process page table is __________
megabytes. [GATE 2016]

Q.7 Recall that Belady’s anomaly is that the pages-fault rate may increase as the number of
allocated frames increases. Now consider the following statements:

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[64]
OPERATING SYSTEM GATE-PSUs-UGC-NET

S1: Random page replacement algorithm (where a page chosen at random is replaced)
suffers from Belady’s anomaly.
S2: LRU page replacement algorithm suffers Belady’s anomaly.
Which of the following is CORRECT? [GATE 2017]
(A) S1 is true, S2 is true (B) S1 is true, S2 is false
(C) S1 is false, S2 is true (D) S1 is false, S2 is false

Q.8 Consider a process executing on an operating system that uses demand paging. The
average time for a memory access in the system is M units if the corresponding memory
page is available in memory and D units if the memory access causes a page fault. It has
been experimental measured that the average time taken for a memory access in the
process is X units.
Which one of the following is the correct expression for the page fault rate experienced
by the process? [GATE 2018]
(A) (D – M) / (X – M) (B) (X – M) / (D – M)
(C) (D – X) / (D – M) (D) (X – M) / (D – X)

Q.9 The size of the physical address space of a processor is 2P bytes. The word length is 2W
bytes. The capacity of cache memory is 2N bytes. The size of each cache block is 2M
words. For a K-way set-associative cache memory, the length (in number of bits) of the
tag field is [GATE 2018]
(A) P − N − log2K (B) P − N + log2K
(C) P − N − M − W − log2K (D) P − N − M − W + log2K

ANSWER KEY
1. (B) 2. (7) 3. (D) 4. (*) 5. (*) 6. (384)
7. (B) 8. (B) 9. (B)

SOLUTION

Sol.1 First In First Out (FIFO)


This is the simplest page replacement algorithm. In this algorithm, operating system
keeps track of all pages in the memory in a queue; oldest page is in the front of the queue.
When a page needs to be replaced page in the front of the queue is selected for removal.
Optimal Page replacement:
in this algorithm, pages are replaced which are not used for the longest duration of time
in the future. Least Recently Used (LRU) In this algorithm page will be replaced which is
least recently used.
Solution:
the virtual page reference string is 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 size of main memory pages
frames is 3.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[65]
OPERATING SYSTEM GATE-PSUs-UGC-NET

For FIFO: total no of page faults are 6 (depicted in red)

For optimal: total no of page faults are 5 (depicted in red)

For LRU: total no of page faults are 9 (depicted in red)

The Optimal will be 5, FIFO 6 and LRU 9. so, OPTIMAL < FIFO < LRU option (B) is
correct

Sol.2 initially all empty frames fill by 1, 2, 3 so all time page fault which is 3.
Then next 4 was not available in frame set so, we look at ahead of request which was
coming last we replace 4 with that so, 3 will be replace by 4 and like wise next 2 and 1 is
present already, so no. page fault and then next 5 is not present so, replace with 1 and
then 3 was not present and replace with 5 and then 2 and 4 are present already so no page
fault and then last 6th was not already there so, page fault.
So, total page fault at : 1, 2, 3, 4, 5, 3, 6. so, total 7 page fault occur ...

Sol.3 It will be (D) i.e. Most-recently-used.


To be clear "repeats the access sequence THRICE" means totally the sequence of page
numbers are accessed 4 times though this is not important for the answer here.
If we go optimal page replacement algorithm it replaces the page which will be least used
in near future.
Now we have frame size 20 and reference string is
1,2,…,100,1,2,…,100,1,2,…,100,1,2,…,100
First 20 accesses will cause page faults - the initial pages are no longer used and hence
optimal page replacement replaces them first. Now, for page 21, according to reference
string page 1 will be used again after 100 and similarly 2 will be used after 1 so, on and
so the least likely to be used page in future is page 20. So, for 21st reference page 20 will
be replaced and then for 22nd page reference, page 21 will be replaced and so on which
is MOST RECENTLY USED page replacement policy.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[66]
OPERATING SYSTEM GATE-PSUs-UGC-NET

PS: Even for Most Recently Used page replacement at first all empty (invalid) pages
frames are replaced and then only most recently used ones are replaced.

Sol.4 What is a Page fault? An interrupt that occurs when a program requests data that is not
currently in real memory. The interrupt triggers the operating system to fetch the data
from a virtual memory and load it into RAM.
Now, 4, 7, 6, 1, 7, 6, 1, 2, 7, 2 is the reference string, you can think of it as data requests
made by a program.
Now the system uses 3 page frames for storing process pages in main memory. It uses
the Least Recently Used (LRU) page replacement policy.
[ ] - Initially page frames are empty i.e. no process pages in main memory.
[4] - Now 4 is brought into 1st frame (1st page fault)
Explanation: Process page 4 was requested by the program, but it was not in the main
memory(in form of page frames),which resulted in a page fault, after that process page 4
was brought in the main memory by the operating system.
[4 7] - Now 7 is brought into 2nd frame (2nd page fault) - Same explanation.
[4 7 6] - Now 6 is brought into 3rd frame (3rd page fault)
[1 7 6] - Now 1 is brought into 1st frame, as 1st frame was least recently used(4th page
fault).
After this 7, 6 and 1 are were already present in the frames hence no replacements in
pages.
[1 2 6] - Now 2 is brought into 2nd frame, as 2nd frame was least recently used(5th
page fault).
[1 2 7] -Now 7 is brought into 3rd frame, as 3rd frame was least recently used(6th page
fault).
Hence, total number of page faults(also called pf) are 6

Sol.5 Requested Page references 3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3 and no. of page frame


size is 5.
In FIFO Page replacement will take place in sequence in pattern First In first Out, as
following
Request 3 8 2 3 9 1 6 3 8 9 3 6 2 1 3
Frame 5 1 1 1 1 1 1 1 1 1 1
Frame 4 9 9 9 9 9 9 9 9 9 2 2
Frame 3 2 2 2 2 2 2 8 8 8 8 8 8 8
Frame 2 8 8 8 8 8 8 3 3 3 3 3 3 3 3
Frame 1 3 3 3 3 3 3 6 6 6 6 6 6 6 6 6
Miss/Hit F F F H F F F F F H H H H F H
No. of Faults = 9 No. of Hits = 6
Using Least Recently Used (LRU) page replacement will be the page which is visited
least recently (which is not used by long time), as following
Request 3 8 2 3 9 1 6 3 8 9 3 6 2 1 3

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[67]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Frame 5 1 1 1 1 1 1 1 2 2 2
Frame 4 9 9 9 9 9 9 9 9 9 9 9
Frame 3 2 2 2 2 2 2 8 8 8 8 8 1 1
Frame 2 8 8 8 8 8 6 6 6 6 6 6 6 6 6
Frame 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Hit/Miss F F F H F F F H F H H H F F H

No. of Faults = 9 No. of Hits = 6


So, both incur the same number of page faults.

Sol.6 Size of memory = 240


Page size = 16KB = 214
No of pages= size of Memory/ page size = 240 / 214 = 226
Size of page table = 226 * 48/8 bytes = 26*6 MB =384 MB

Sol.7 Belady’s anomaly proves that it is possible to have more page faults when increasing the
number of page frames while using the First in First Out (FIFO) page replacement
algorithm. For example, if we consider reference string 3 2 1 0 3 2 4 3 2 1 0 4 and 3 slots,
we get 9 total page faults, but if we increase slots to 4, we get 10 page faults.
S1: Random page replacement algorithm (where a page chosen at random is replaced)
suffers from Belady’s anomaly.
-> Random page replacement algorithm can be any including FIFO so its true
S2: LRU page replacement algorithm suffers from Belady’s anomaly.
-> LRU does’nt suffer from Belady’s anomaly .
Therefore, option B is correct

Sol.8 Let P be the page fault rate.


Average memory access time = (1− page fault rate) × memory access time when no page
fault + Page fault rate × Memory access time when page fault.
X = (1 − P)M + P D
X = M + P(D − M)
P = (X − M) / (D − M)
(B) is the answer.

Sol.9 Physical Address Space = 2P Bytes. Word Length is 2W bytes, which means each word is
of size 2W bytes.
Cache memory size = 2N Bytes and Tag Size = 2X Bytes.
Physical address is P – W bits
Number of blocks in cache = 2(N-W-M)
It is a K-way set associative cache memory each set in cache will have K-blocks.
So, Number of sets = 2(N-W-M)/ K

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[68]
OPERATING SYSTEM GATE-PSUs-UGC-NET

SET bits will be N-W-M-logk


Offset bits will be M
We know,
TAG bits = Main memory bits – SET bits – offset bits
So, TAG bits(x) = P – W – (N-M-W-logk)- M
= P – W – N + M + W + logk – M
x = P – N + logk
Option (B) is Correct.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[69]
OPERATING SYSTEM GATE-PSUs-UGC-NET

FILE MANAGEMENT
Q.1 A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, I
indirect block address and 1 doubly indirect block address. The size of each disk block is
128 Bytes and the size of each disk block address is 8 Bytes. The maximum possible file
size in this file system is [GATE 2012]
(A) 3 Kbytes (B) 35 Kbytes
(C) 280 Bytes (D) Dependent on the size of the disk

Q.2 A FAT (file allocation table) based file system is being used and the total overhead of
each entry in the FAT is 4 bytes in size. Given a 100×106 bytes disk on which the file
system is stored and data block size is 103bytes, the maximum size of a file that can be
stored on this disk in units of 106 bytes is _________. [GATE 2014]

Q.3 Consider a disk queue with requests for I/O to blocks on cylinders 47, 38, 121, 191, 87,
11, 92, 10. The C-LOOK scheduling algorithm is used. The head is initially at cylinder
number 63, moving towards larger cylinder numbers on its servicing pass. The cylinders
are numbered from 0 to 199. The total head movement (in number of cylinders) incurred
while servicing these requests is_________. [GATE 2016]

Q.4 Consider a computer system with ten physical page frames. The system is provided with
an access sequence a1, a2, …, a20, a1, a2, …, a20), where each ai is a distinct virtual page
number. The difference in the number of page faults between the last-in-first-out page
replacement policy and the optimal page replacement policy is ____ [GATE 2016]

Q.5 In which one of the following page replacement algorithms it is possible for the page
fault rate to increase even when the number of allocated frames increases?
(A) LRU (Least Recently Used) (B) OPT (Optimal Page Replacement)
(C) MRU (Most Recently Used) (D) FIFO (First In First Out)
[GATE 2016]

Q.6 Consider a storage disk with 4 platters (numbered as 0, 1, 2 and 3), 200 cylinders
(numbered as 0, 1, … , 199), and 256 sectors per track (numbered as 0, 1, … 255). The
following 6 disk requests of the form [sector number, cylinder number, platter number]
are received by the disk controller at the same time:
[120, 72, 2], [180, 134, 1], [60, 20, 0], [212, 86, 3], [56, 116, 2], [118, 16, 1]
Currently head is positioned at sector number 100 of cylinder 80, and is moving towards
higher cylinder numbers. The average power dissipation in moving the head over 100
cylinders is 20 milliwatts and for reversing the direction of the head movement once is
15 milliwatts. Power dissipation associated with rotational latency and switching of head
between different platters is negligible.
The total power consumption in milliwatts to satisfy all of the above disk requests using
the Shortest Seek Time First disk scheduling algorithm is ______ . [GATE 2018]

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[70]
OPERATING SYSTEM GATE-PSUs-UGC-NET

ANSWER KEY
1. (B) 2. (99.60) 3. (346) 4. (1) 5. (D) 6. (85)

SOLUTION
Sol.1 Direct block addressing will point to 88 disk blocks =8 × 128 B=1 KB
Singly Indirect block addressing will point to 1 disk block which has 128/8 disc block
addresses = (128/8) × 128 B = 2 KB
Doubly indirect block addressing will point to 1 disk block which
has 128/8128/8 addresses to disk blocks which in turn has 128/8 addresses to disk
blocks = 16 × 16 × 128 B = 32 KB
Total = 35 KB
Answer is (B).

Sol.2 Here block size is 10^3 B.


No. of entries in the FAT = Disk capacity/ Block size
= 10^8/10^3
= 10^5
Total space consumed by FAT = 10^5 *4B
= 0.4*10^6B
Max. size of file that can be stored = 100*10^6-0.4*10^6
= 99.6*10^6B.
So answer 99.6.

Sol.3 The head movement would be:


63 => 87 24 movements
87 => 92 5 movements
92 => 121 29 movements
121 => 191 70 movements
191 --> 10 181 movement
10 => 11 1 movement
11 => 38 27 movements
38 => 47 9 movements
Total head movements = 346

Sol.4 Answer is 1.
In LIFO first 20 are page faults followed by next 9 hits then next 11 page faults.
(After a10, a11 replaces a10, a12 replaces a11 and so on)
In optimal first 20 are page faults followed by next 9 hits then next 10 page faults
followed by last page hit.

Sol.5 In some situations FIFO page replacement gives more page faults when increasing the
number of page frames. This situation is Belady’s anomaly.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[71]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Belady’s anomaly proves that it is possible to have more page faults when increasing the
number of page frames while using the First in First Out (FIFO) page replacement
algorithm. For example, if we consider reference string 3 2 1 0 3 2 4 3 2 1 0 4 and 3 slots,
we get 9 total page faults, but if we increase slots to 4, we get 10 page faults.

Sol.6 Head starts at 80.

Total Head movements in SSTF = (86-80) + (86-72) + (134-72) + (134-16) = 200


Power dissipated by 200 movements : P1 = 0.2 * 200 = 40 mW
Power dissipated in reversing head direction once = 15 mW
Number of time Head changes its direction = 3
Power dissipated in reversing head direction: P2 = 3 * 15 = 45 mW
Total power consumption (in mW) is P1 + P2 = 40 mW + 45 mW = 85 mW
So, answer is 85.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[72]
OPERATING SYSTEM GATE-PSUs-UGC-NET

I/O MANAGEMENT
Q.1 Suppose a disk has 201 cylinders, numbered from 0 to 200. At some time the disk arm is
at cylinder 100, and there is a queue of disk access requests for cylinders 30, 85, 90, 100,
105, 110, 135 and 145. If Shortest-Seek Time First (SSTF) is being used for scheduling
the disk access, the request for cylinder 90 is serviced after servicing ____________
number of requests. [GATE 2014]

Q.2 Suppose the following disk request sequence (track numbers) for a disk with 100 tracks
is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial position of the R/W
head is on track 50. The additional distance that will be traversed by the R/W head when
the Shortest Seek Time First (SSTF) algorithm is used compared to the SCAN (Elevator)
algorithm (assuming that SCAN algorithm moves towards 100 when it starts execution)
is _________ tracks [GATE 2015]

Q.3 Consider an operating system capable of loading and executing a single sequential user
process at a time. The disk head scheduling algorithm used is First Come First Served
(FCFS). If FCFS is replaced by Shortest Seek Time First (SSTF), claimed by the vendor
to give 50% better benchmark results, what is the expected improvement in the I/O
performance of user programs? [GATE 2004]
(A) 50% (B) 40% (C) 25% (D) 0%

ANSWER KEY
1. (3) 2. (10) 3. (D)

SOLUTION
Sol.1 In Shortest-Seek-First algorithm, request closest to the current position of the disk arm
and head is handled first.
In this question, the arm is currently at cylinder number 100. Now the requests come in
the queue order for cylinder numbers 30, 85, 90, 100, 105, 110, 135 and 145.
The disk will service that request first whose cylinder number is closest to its arm. Hence
1st serviced request is for cylinder no 100 (as the arm is itself pointing to it), then 105,
then 110, and then the arm comes to service request for cylinder 90. Hence before
servicing request for cylinder 90, the disk would had serviced 3 requests.

Sol.2 SSTF:

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[73]
OPERATING SYSTEM GATE-PSUs-UGC-NET

SCAN

So, for SSTF it takes 130 head movements and for SCAN it takes 140 head movements.
Hence, not additional but 140−130=10 less head movements SSTF takes.

Sol.3 Question says "single sequential user process". So, all the requests to disk scheduler will
be in sequence and each one will be blocking the execution and hence there is no use of
any disk scheduling algorithm. Any disk scheduling algorithm gives the same input
sequence and hence the improvement will be 0% for SSTF over FCFS.

PROCESS & THREDS

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[74]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Q.1 Which of the following is/are shared by all the threads in a process?
I. Program counter [GATE 2017]
II. Stack
III. Address space
IV. Registers
(A) I and II only (B) III only (C) IV only (D) III and IV only

Q.2 Threads of a process share [GATE 2017]


(A) global variables but not heap (B) heap but not global variables
(B) neither global variables nor heap (D) both heap and global variables

Q.3 A multithreaded program P executes with x number of threads and uses y number of
locks for ensuring mutual exclusion while operating on shared memory locations. All
locks in the program are non-reentrant, i.e., if a thread holds a lock l, then it cannot re-
acquire lock l without releasing it. If a thread is unable to acquire a lock, it blocks until
the lock becomes available. The minimum value of x and the minimum value of y
together for which execution of P can result in a deadlock are: [GATE 2017]
(A) x = 1, y = 2 (B) x = 2, y = 1 (C) x = 2, y = 2 (D) x = 1, y = 1

ANSWER KEY
1. (B) 2. (D) 3. (C)

SOLUTION
Sol.1 Thread is light weight process, and every thread have its own, stack, register, and PC
(one of the register in CPU contain address of next instruction to be executed), so only
address space that is shared by all thread for a single process.
So, option (B) is correct answer.

Sol.2 A thread shares with other threads a process’s (to which it belongs to) :
 Code section
 Data section (static + heap)
 Address Space
 Permissions
 Other resources (e.g. files)
Therefore, (D) is the answer.

Sol.3 Reentrant (Recursive) locks allow a thread to reacquire the lock. That means same
process can claim the lock multiple times without blocking on itself. This prevents the
thread from deadlocking itself. This is main advantage of reentrant locks over non-
reentrant locks.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[75]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Non-reentrant (Non-recursive) locks not allow a thread to reacquire the lock. That means
same process cannot claim the lock multiple times without releasing it. So, if a
thread/process is unable to acquire a lock, it blocks until the lock becomes available. This
situation is deadlocked.
Therefore, only one thread and only one lock can cause deadlock, if thread does try to
reacquire lock.
When we have more than one process or one lock, then process/thread can acquire
another lock to proceed further, or other process/thread can acquire lock to proceed
further.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[76]
OPERATING SYSTEM GATE-PSUs-UGC-NET

TIFR Previous Years Questions


Q.1 Consider the concurrent program: [TIFR 2010]
x := 1;
cobegin
x:= x + 3 || x := x + x + 2
coend
Reading and writing of variables is atomic, but the evaluation of an expression is not
atomic. The set of possible values of variable x at the end of the execution of the program
is:
(A) {4} (B) {8} (C) {4, 7, 10} (D) {4, 7, 8, 10}
(E) {4, 7, 8}

Q.2 Consider the following solution (expressed in Dijkstra's guarded command notation) to
the mutual exclusion problem. [TIFR 2010]
process P1 is
begin
loop
Non_critical_section;
while not (Turn=1) do skip od;
Critical_section_1;
Turn=2;
end loop
end

process P2 is
begin
loop
Non_critical_section;
while not (turn=2) do skip od;
Critical_section_2;
Turn=1;
end loop
end
Initially, Turn = 1, Assume that the two process run forever and that no process stays in
its critical or non-critical section infinitely. A mutual exclusion program is correct if it
satisfies the following requirements.
1. Only one process can be in a critical region at a time.
2. Program is a dead-lock free, i.e., if both processes are trying to enter the critical region
then at least one of them does enter the critical region.
3. Program is starvation-free; i.e, a process trying to enter the critical region eventually
manages to do so.
The above mutual exclusion solution.
(A) Does not satisfy the requirement (1).

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[77]
OPERATING SYSTEM GATE-PSUs-UGC-NET

(B) Satisfy the requirement (1) but does not satisfy the requirement (2).
(C) Satisfies the requirements (1) and (2), but does not satisfies the requirement (3).
(D) Satisfies the requirement (1) and (3), but does not satisfies the requirement (2).
(E) Satisfies all the requirement (1), (2), and (3).

Q.3 Consider a basic block x:= a[i]; a[j]:= y; z:= a[j] optimized by removing common sub
expression a[i] as follows x:= a[i]; z:= x; a[j]:= y.
Which of the following is true? [TIFR 2011]
(A) Both are equivalent.
(B) The values computed by both are exactly the same.
(C) Both give exactly the same values only if i is not equal to j.
(D) They will be equivalent in concurrent programming languages with shared memory.
(E) None of the above.

Q.4 Consider the following two scenarios in the dining philosophers problem:
i. First a philosopher has to enter a room with the table that restricts the number of
philosophers to four.
ii. There is no restriction on the number of philosophers entering the room.
Which of the following is true? [TIFR 2011]
(A) Deadlock is possible in (i) and (ii). (B) Deadlock is possible in (i).
(C) Starvation is possible in (i). (D) Deadlock is not possible in (ii).
(E) Starvation is not possible in (ii)

Q.5 Consider the class of synchronization primitives. Which of the following is false?
(A) Test and set primitives are as powerful as semaphores.
(B) There are various synchronizations that can be implemented using an array of
semaphores but not by binary semaphores.
(C) Split binary semaphores and binary semaphores are equivalent.
(D) All statements a - c are false.
(E) Petri nets with and without inhibitor arcs have the same power. [TIFR 2011]

Q.6 Consider malware programs. Which of the following is true? [TIFR 2011]
(A) A worm is a parasite.
(B) A virus cannot affect a linux operating system.
(C) A trojan can be in the payload of only a worm.
(D) A worm and virus are self replicating programs.
(E) There is no difference between a virus and a worm.

Q.7 Consider the concurrent program [TIFR 2012]


x := 1;
cobegin
x:= x + x + 1 || x := x + 2
coend;

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[78]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Reading and writing of a variable is atomic, but evaluation of an expression is not


atomic. The set of possible values of variable x at the end of execution of the program is
(A) {3} (B) {7} (C) {3, 5, 7} (D) {3, 7}
(E) {3, 5}

Q.8 Consider the blocked-set semaphore where the signaling process awakens any one of the
suspended process; i.e. [TIFR 2012]
Wait (S): If S > 0 then S ← S − 1, else suspend the execution of this process.
Signal (S): If there are processes that have been suspended on semaphore S, then wake
any one of them, else S ← S + 1
Consider the following solution of mutual exclusion problem using blocked-set
semaphores.
s := 1;
cobegin
P(1) || P(2) || ..... || P(N)
coned
Where the task body P(i) is
begin
while true do
begin
<non critical section>
Wait (S)
<critical section>
Signal (S)
end
end
Here N is the number of concurrent processors. Which of the following is true?
(A) The program fails to achieve mutual exclusion of critical regions.
(B) The program achieves mutual exclusion, but starvation freedom is ensured only for
N≤2
(C) The program does not ensure mutual exclusion if N ≥ 3
(D) The program achieves mutual exclusion, but allows starvation for any N ≥ 2
(F) The program achieves mutual exclusion and starvation freedom for any N ≥ 1

Q.9 Assume a demand paged memory system where ONLY THREE pages can reside in the
memory at a time. The following sequence gives the order in which the program
references the pages. [TIFR 2013]
1, 3, 1, 3, 4, 2, 2, 4
Assume that least frequently used page is replaced when necessary. If there is more than
one least frequently used page then the least recently used page among them is replaced.
During the program’s execution, how many times will the pages 1, 2, 3 and 4 be brought
to the memory?
(A) 2, 2, 2, 2 times, respectively (B) 1, 1, 1, 2 times, respectively

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[79]
OPERATING SYSTEM GATE-PSUs-UGC-NET

(C) 1, 1, 1, 1 times, respectively (D) 2, 1, 2, 2 times, respectively


(E) None of the above

Q.10 Consider the following concurrent program (where statements separated by || with-in
cobegin-coend are executed concurrently). [TIFR 2015]
x:=1
cobegin
x:= x + 1 || x:= x + 1 || x:= x + 1
coend
Reading and writing of variables is atomic but evaluation of expressions is not atomic.
The set of possible values of x at the end of execution of the program is
(A) {4} (B) {2, 3, 4} (C) {2, 4} (D) {2, 3}
(E) {2}

ANSWER KEY
1. (C) 2. (C) 3. (*) 4. (C) 5. (*) 6. (D)
7. (C) 8. (B) 9. (B) 10. (B)

SOLUTION
Sol.1 cobegin
x:= x + 3 || x := x + x + 2
coend
This implies that the two statements x:= x + 3 and x := x + x + 2 can execute sequentially
as well as parallelly.
Now,
Sequential part:
x:= x + 3 || x:= x + x + 2
First run x = x + 3, value of x becomes 4
Now x = 4 run x = x + x + 2 value of x will be 4 + 4 + 2 = 10
Finally x becomes 10
------------------
Parallel part:
Initialized value of x = 1
Both will take x as 1 initially and then run independently, so
x=x+3=1+3=4
x=x+x+2=1+1+2=4
But final write will be done by the process x = x + x + 2
It will give value 4.
x = x + x + 2 completed its execution before x = x + 3.
Then, x = x + 3 will read value of x as 4 and then x = x + 3 i.e. x = 4 + 3 = 7
So, here we get {4, 7}

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[80]
OPERATING SYSTEM GATE-PSUs-UGC-NET

Final answer is combination of both sequential and parallel part:


which is {4, 7, 10}
Option (C).

Sol.2 Process P1 while loop says: while NOT (turn =1) do. so, it will not enter the while loop
until Turn = 2 which will make Turn = 1 false and thus NOT (Turn =1) as true.
Process P2 for the same reason will enter the while loop.
As process P2 has statement Turn = 1 at the end of the while loop so the value of Turn
will always remain 1. So, process P1 will never enter the while loop and so, this will
result in starvation of Process P1.
Hence, answer is (C).

Sol.3 As in 1st z = a[j] = y


whereas in 2nd z = x = a[i]
So, z is getting different values if i ≠ j
(Also there's typo in question, expression a[j] has been removed)

Sol.4 Option C
i. is a solution to Dining Philosophers problem mentioned in Galvin. Of course this
assumes that the number of forks is 55 and the number of philosophers is 44. This
guarantees no deadlock, but starvation is possible as here a philosopher who
finishes his meal can again get access to the forks whereas some philosopher may
not get fork ever leading to his starvation. So, option (C) is TRUE.

ii. is the Dining Philosophers problem with no restriction on the number of


philosophers which can cause deadlock and deadlock implies starvation. So,
options (D) and (E) are FALSE.

Sol.5 (a) True. A test and set primitive can be used in place of a semaphore
(b) True (Example: multiple process synchronization to a critical section access)
(c) False. A split binary semaphore is essentially an array of binary semaphores
(d) False as (a) and (b) are true
(e) False as seen from the definition of inhibitor arc here

Sol.6 D is choice
 A worm is a parasite. False
ANS: worm is a standalone malware computer program that replicates itself in order to
spread to other computers.
 A virus cannot affect a Linux operating system. False
ANS: virus can affect any operating system.
 A trojan can be in the payload of only a worm. False
 A worm and virus are self-replicating programs. True
ANS: worm and virus is self-replicating programs But trojan is not.

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[81]
OPERATING SYSTEM GATE-PSUs-UGC-NET

 There is no difference between a virus and a worm. False


ANS: since worm are standalone software and do not require a host program or human
help to propagate.
So, D is choice.

Sol.7 1. x = 1, Run x = x + 2 then x = x + x + 1 finally x will be 7.


2. x = 1, run x = x + 2 and x = x + x + 1, parallel.
x = 5, 3
Final answer would be {3, 5, 7}

Sol.8 (B) is correct option!


Wait (S): If S > 0 then S ← S − 1, else suspend the execution of this process.
Signal (S): If there are processes that have been suspended on semaphore S, then wake
any one of them, else S ← S + 1
Suppose there are only 2 processes in the system i.e., N = 2.
s :=1
cobegin
P(1) | P(2);
coend;
There are two concurrent processes lets say P1 and P2, which are trying to to access
critical section, by executing P(1) and P(2) respectively.
Suppose P(1) gets executed first, and it makes s=0.
when P(2) executes Wait(S) then P2 will be blocked when P1 executes Signal(S), there
is one suspended process, hence P2 will be waken up and be placed into ready queue,
now it can execute its critical section. The value of S is still 0, hence ME is satisfied.
There is only 1 process in the suspended state, hence there is no chance that it will starve
because as soon as the other process performs signal operation this process will be
waken up
If N>2, then there is a chance that multiple processes are blocked, and a random
process will be unblocked when a process perform signal(S) operation, there is a chance
that one blocked process is not getting its chance hence it might starve. So, (E) is not
correct option.
PS: A blocked queue semaphore awakens processes in the order they are suspended-
hence no starvation even for N > 2 if used in this question.

Sol.9 Page reference order: 1, 3, 1, 3, 4, 2, 2, 4


First 2 pages causes page fault. I.e. 1 and 3
Next 2 pages no fault.
Next page i.e. 4 fault occurs.
Now for page no. 2 we have fault. We will replace less frequently used i.e. 4
Next page is again 2 so no. page fault.
Now page no. 12 and 3 all are used 2 times so, we will replace page 1 to accommodate
page 4 (least recently used is 1)

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[82]
OPERATING SYSTEM GATE-PSUs-UGC-NET

So, page 123 are brought once in memory and page 4 is brought two times so, answer is
(B).

Sol.10 Reading and writing is atomic but evaluation not atomic


So,
1. read 1, evaluate 1 time, write 2
2. read 1, evaluate 2 time, write 3
3. read 1, evaluate 3 time, write 4
Answer will be (B) 2, 3, 4

i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[83]

You might also like