Professional Documents
Culture Documents
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.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
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.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.
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.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.7 (A) After successful completion of a program 0 is returned to the operating system.
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.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
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.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
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
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.
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
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.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
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
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
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.
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
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:
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.
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.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.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".
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.9 Wait and signal are the atomic operation possible on semaphore.
So, (D) is the correct option.
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:
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.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.
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[22]
OPERATING SYSTEM GATE-PSUs-UGC-NET
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.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
Sol.8 Answer C
P1 holds 3 resources
P2 holds 4 resources
P3 holds 2 resources
P4 holds 1 resource
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.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
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.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
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.
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.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.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
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
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[34]
OPERATING SYSTEM GATE-PSUs-UGC-NET
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
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
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[36]
OPERATING SYSTEM GATE-PSUs-UGC-NET
Sol.10
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
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.15
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[38]
OPERATING SYSTEM GATE-PSUs-UGC-NET
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.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
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.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.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
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.
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
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.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
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
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
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.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
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.
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.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
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[57]
OPERATING SYSTEM GATE-PSUs-UGC-NET
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:
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
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
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.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
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
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[65]
OPERATING SYSTEM GATE-PSUs-UGC-NET
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 ...
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
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
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.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
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.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.
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.
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.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
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.
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[78]
OPERATING SYSTEM GATE-PSUs-UGC-NET
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
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
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.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.
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
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).
i-GATE,B-713, Street 22, Smriti Nagar, Bhilai, Durg, CG- 490020, Contact 98271-62352, 96440-14000
[83]