Professional Documents
Culture Documents
Operating System: Computer Science
Operating System: Computer Science
For
COMPUTER SCIENCE
.
OPERATING SYSTEM
SYLLABUS
Processes, threads, interprocess communication, concurrency and synchronization.
Deadlock. CPU scheduling. Memory management and virtual memory. File systems.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
CONTENTS
Topics Page No
1. PROCESS AND DEADLOCK
2. MEMORY MANAGEMENT
2.1 Introduction 53
2.2 Single Partition Allocation 55
2.3 External & Internal Fragmentation 56
2.4 Segmentation 58
2.5 Fragmentation 59
2.6 Virtual Memory 59
2.7 Page Replacement 60
2.8 Demand Paging 61
2.9 Page-Replacement 61
2.10 Counting Algorithms 63
2.11 Allocation of Frames 63
2.12 Thrashing 64
Gate Questions 65
3. INTERRUPTS
3.1 Introduction 78
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
3.2 Interrupts 78
3.3 Applications I/O Interface 79
3.4 Block and Character Devices 79
3.5 Kernel I/O subsystems 79
3.6 Performance 81
3.7 Stable-Storage Implementation 83
Gate Questions 85
4. FILE-MANAGEMENT
4.1 Introduction 88
4.2 File Concept 88
4.3 Access Methods 89
4.4 Single-Level Directory 91
4.5 Types of Access 91
4.6 Allocation Methods 92
4.7 Free-Space Management 94
4.8 Directory Implementation 94
Gate Questions 96
5. ASSIGNMENT QUESTIONS 99
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
1 PROCESS & DEADLOCK
PRI AT BT CT TA W RT
Pno ORI T T
TY
1 2 0 4 25 25 21 0
2 4 1 2 22 21 19 0
3 6 2 3 21 19 16 0
4 10 3 5 12 9 4 0
5 8 4 1 19 15 14 14
6 12 5 4 9 4 0 0
7 9 6 6 18 12 6 6
Advantages: Different Scheduling
algorithms can be applied for different
Gantt chart: queues.
P P P P P P P P P P P P Disadvantages: As long as there is a single
1 2 3 4 4 6 4 7 5 3 2 1 process in highest queue, no process from
0 1 2 3 4 5 9 12 18 19 21 22 25 lower queues will get a chance.
FCFS NP- SRT RR PRIORI PRIOR LJF- LRTF HRR MULTILEV MULTILEVEL
SJF F TY-NP ITY-P NP N EL QUEUE FEEDBACK
QUEUE
NO YES YES NO YES YES YES YES NO YES NO
1.8.4.3 No Preemption
To ensure that this condition does hold, we We claim that the system is not in a
can use following protocol. If a process deadlocked state. Indeed, if we execute our
that is hold some resources requests algorithm, we will find that the sequence <
another resource that cannot be P0, P2 P3, P1 P4 > will result in Finish[i] = true
immediately allocated to it (that is, the for all i. Now suppose that process P2
process must wait), then all resources makes one additional request for an
currently being held are preempted. That instance of type C. The Request matrix is
is, these resources are implicitly released. modified as follows:
The preempted resources are added to the Request
list of resources for which the process is
P0 0 0 2
waiting. The process will be restarted only
P1 2 0 2
when it can regain its old resources, as well
P2 0 0 1
as the new ones that it is requesting.
P3 1 0 0
P4 0 0 2
An alternative protocol allows a process to
request resources only when the process
has none. A process may request some We can say that the system is now
resources and use them. Before it can deadlocked. Although we can reclaim the
request any additional consider a system resources held by process P0 the number of
with five processes Po through P4 and three available resources is not sufficient to fulfill
resources that it is currently allocated. the requests of the other processes. Thus, a
deadlock exists, consisting of processes P1,
P2, P3, and P4.
1.8.4.4 Detection-Algorithm Usage a) Selecting a victim
When should we invoke the detection Which resources and which processes
algorithm? The answer depends on two are to be preempted? As is process
factors: termination, we must determine the
order of preemption to minimize cost.
i) How often is a deadlock likely to occur? Cost factors may include such
ii) How many processes will be affected by parameters as the number of resources
deadlock when it happens? a deadlock process is holding, and the
amount of time a deadlock process has
1.8.5 Recovery from Deadlock thus far consumed during its
execution.
1.8.5.1 Process Termination
To eliminate deadlocks by aborting a b) Rollback
process, we use one of two methods. In both If we preempt a resource from a
methods, the system reclaims all resources process, what should be done with that
allocated to the terminated processes. process? Clearly, it cannot continue
with its normal execution; it is missing
some needed resource. We must roll
i) Abort all deadlocked processes back the process to some safe state,
This method clearly will break the and restart it from that state.
deadlock cycle, but at a great expense, Since, in general, it is difficult to
since these processes may have determine what a safe state is, the
computed for a long time, and the simplest solution is a total rollback:
results of these partial computations Abort the process and then restart it.
must be discarded, and probably However, it is more effective to roll
must be recomputed later. back the process only as far as
necessary to break the deadlock.
ii) Abort one process at a time until
the deadlock cycle is eliminated c) Starvation
This method incurs considerable How do we ensure that starvation will
overhead, since, after each process is not occur? That is, how can we
aborted, a deadlock-detection guarantee that resources will not
algorithm must be invoked to always be preempted from the same
determine whether any processes are process? In a system where victim
still deadlocked. selection is based primarily on cost
factors, it may happen that its
1.8.5.2 Resource Preemptions designated task, a starvation situation
To eliminate deadlock using resource that needs to be dealt with in any
preemption, we successively preempt practical system. Clearly, we must
some resources and give these resources ensure that a process can be picked as
to other processes until the deadlock cycle a victim only a (small) finite number of
is broken. If preemption is required to deal times. The most common solution is to
with deadlocks, then there issues need to include the number of rollbacks in the
be addressed: cost factor.
1.9 THERE ARE THREE TYPES OF PROBLEMS WITH IPC:
Inconsistency.
Loss of data.
Deadlock.
STEPS: STEPS:
Produce Item. 1. Check condition to
Check condition to wait (sleep) or polling.
Wait (sleep) or polling. 2. Increment OUT.
BUFFER [IN] = Item. 3. Decrement COUNT.
Increment IN. 4. Consume Item.
Increment COUNT.
Produce_item(temp);Step 1 While(COUNT==0);Step 1
While(COUNT==N);Step 2 Itemc = BUFFER[OUT];
BUFFER[IN] = Item;Step 3 OUT = (OUT+1) %N; Step 2
IN = (IN+1) %N; Step 4 COUNT = COUNT – 1; Step 3
COUNT = COUNT + 1; Step 5 Consume_item(itemc); Step 4
} }
} }
Problems: Load Ri, M [IN] //Read IN.
Store SD [Ri],”Filename” //Make an
Step 5 or producer () and Step 3 of entry.
consumer() are points of focus here. Increment Ri.
Suppose COUNT=4. Store M[IN],Ri //Update IN
Producer puts an item on buffer, but Printer & Spooler suffers from Loss of
before incrementing COUNT, control goes data problem.
to consumer.
Consumer consumes one item, but before Deadlock: Possibility for processes
decrementing COUNT, control goes to entering deadlock is an IPC problem.
producer. Race Condition: When the final value of a
Now, one time increment and one time shared variable depends on the order of
decrement is to be executed. execution of two processes, it is said to be
COUNT++ : 4+1 =5 a race condition.
COUNT--:4-1=3 Example: COUNT variable in Producer
COUNT-- : 5-1 =4 Consumer IN variable in Printer & Spooler
COUNT++: 3+1=4
But increment & decrements are not There are three conditions to achieve
executed in one machine instruction, they Synchronization:
require three machine instructions which Mutual Exclusion: No two processes
are interleaved. are present in the critical section at
the same time.
COUNT++ Progress: No process running outside
R1 = COUNT Critical Section should restrict
R1 = R1 +1 another process to go inside, if
COUNT = R1 Critical section is free.
COUNT— Bounded/Busy waiting: No process has
R2=COUNT to wait forever to enter critical
R2 = R2 – 1 section. If this condition isn’t
COUNT = R2 satisfied, there is a possibility of
This injects inconsistency in the variable starvation.
states.
1.12 SOLUTIONS TO
Producer Consumer suffers with IPC/SYNCHRONIZATION
Inconsistency. This is not compulsory that
it must suffer from all problems. If anyone Some solutions comply with all three
is present, it is an IPC problem conditions, some fail at one or two
conditions.
1.11 PRINTER AND SPOOLER PROBLEM
1.12.1 Software Solutions:
Shared Resource are IN variable and 1.12.1.1 Lock Variable
Spooler Directory. Mutual Exclusion fails.
IN: It is used by processes. Progress is achieved.
Bounded/Busy wait fails here.
Algorithmic steps to enter a file in Spooler Entry Section:
Directory: Load Ri,M[lock]
Cmp Ri,#0 Mutual Exclusion is
Jnz Step 1 satisfied.
Store M[lock],#1 Progress is achieved.
Critical Section Bounded/Busy wait is
Store M[lock],#0 satisfied.
Lock: 0 Critical Section is free.
Lock: 1 Critical Section is busy. 1.12.1.4 Semaphores
Semaphore is a system variable used to
1.12.1.2 Strict Alteration & Decker’s achieve mutual exclusion.
Algorithm The following operations can be
Only alternate sequence is allowed. performed on semaphores:
This approach is restricted to two Down() or P() or Wait()
processes only. Up() or V() or Release() or Signal()
P0 P1
While (true) { While (true) { Semaphores are of two types:
Non_CS () Non_CS () Counting Semaphore:
While (turn! = 0); While (turn! = 1);
CS (); CS (); Down () operations is performed
Turn=1; turn=0; as follows:
} } Value_of_semaphore--;
If(value_of_semaphore<0)
Mutual Exclusion is satisfied. Block process,put it in suspended list.
Progress is not achieved.
Bounded/Busy wait is satisfied. Up () operations is performed as follows:
Value = Value +1
1.12.1.3 Peterson’s Solution If (value <= 0 )
#define N 2 Select a process from suspended list &
#define TRUE 1 wake up.
#define FALSE 0
Int turn; Down () is successful if process is not
//Shared Variable blocked, else unsuccessful.
Int interested [N]; Up () is always successful.
//Shared Variable
II. Binary Semaphore:
Void enter_region(int process){
Int other = 1- process; Down()
Interested[process] = TRUE; {
Turn = process; If(value == 1)
While(turn ==process && S=0
interested[other]==TRUE); Else if(value == 0)
} Block process, put
it in suspended list.
Void leave_region(int process){ }
Interested [process] = FALSE; Up()
} {
If list is non empty, select a COUNT in previous approach is
process & wake up. replaced here by Mutex, Empty,
Else if S==0 or S==1, make Full.
it 1.
} 1.14 Solution to READER & WRITER
Down() is successful when PROBLEM
S=1,unsuccessful when S=0.
Up() is always successful. Multiple readers are allowed to read
database.
1.13 Solution to PRODUCER Writer needs exclusive access i.e. no
CONSUMER PROBLEM using reader, no writer.
SEMAPHORES For writer who is waiting outside, we
have to maintain rc(reader count).
Producer As one reader does rc++,other
reader reads old value, so
While(true){ inconsistency may occur.
Produce(itemp); Therefore, rc requires a semaphore
Down(empty); (mutex).
Down(mutex); Semaphore db: For access to database.
Consumer Down(mutex)
//increment rc & down db
While(true){ Rc = rc+1
// if 1st reader
Down(full); If(rc==1)
Down(mutex); Down(db);
Up(mutex);
Itemc = BUFFER[OUT]; Read();
OUT = (OUT+1) %N; Down(mutex);
Up(mutex); Rc = rc -1;
Up(empty); If(rc==0)
} Up(db);
Up(mutex);
Note: }
Empty + Full = N (Always)
Mutex: Binary Semaphore to access Void writer(){
buffer in mutually exclusive //decrement rc & up(db)
manner. While(TRUE){
Empty: Counting Semaphore //if last reader
Full : Counting Semaphore Down(db)
Write();
Up(db);
}
}
Q.2 A CPU has two modes- privileged Q.6 Consider Peterson's algorithm for
and non- privileged. In order to mutual exclusion between two
change the mode from privileged concurrent processes I and j. The
to non- privileged program executed by process is
a) a hardware interrupt is needed shown below.
b) a software interrupt is needed repeat flag [i] = true;
c) a privileged instruction (which turn = j ;
does not generate an interrupt) while (P) do no-op;
is needed. Enter critical section, perform
d) a non-privileged instruction actions, then exit critical section
(which does not generate an Flag [i] = false;
interrupt) is needed. Perform other non-critical section
[GATE -2001] actions. Until false;
For the program to guarantee
Q.3 Consider a set of n tasks with mutual exclusion, the predicate P
known runtimes r1 , r2 ,, rn to be in the while loop should be
run on a uni-processor machine. a) flag [j]= true and turn = i
Which of the following processor b) flag [j] = true and turn = j
scheduling algorithms will result c) flag [i]= true and turn = j
in the maximum throughput? d) flag [i] = true and turn = i
a) Round Robin [GATE-2001]
b) Shortest Job First
c) Highest Response Ratio Next Q.7 Which combination of the
d) First Come First Served following features will suffice to
[GATE-2001] characterize an operating system
as a multi-programmed operating
Q.4 Which of the following scheduling system?
algorithms is non-pre-emptive? A) More than one program may be
a) Round Robin loaded into main memory at
b) First-in-First out the same time for execution.
B) If a program waits for certain Common Data for Questions 10 and 11:
events such as IN/OUT, Suppose we want to synchronize two
another program is concurrent processes P and Q using
immediately scheduled for binary semaphores S and T. The code for
execution. the processes P and Q is shown below.
C) If the execution of a program Process P
terminates, another program is While (1)
immediately scheduled for {
execution. W:
a) (A) only b) (A) and (B) Print ‘0’;
c)(A) and (C) d) (A)(B)and(C) Print ‘0’;
[GATE-2002] X:
}
Q.8 Draw the process state transition Process Q
diagram of an OS in which (i) each while (1)
process is in one of the five states: {
created, ready, running, blocked Y:
(i.e. sleep or wait). Or terminated, print ‘1’
and (ii) only non- preemptive print ‘1’
scheduling is used by the OS Label Z:
the transitions appropriately. Synchronization statements can be
[GATE -2002] inserted only at points W, X, Y and Z.
Q.9 A uni-processor computer system Q.10 Which of the following will always
only has two processes, both of lead to an output starting with?
which alternate 10 ms CPU bursts 01100110011'?
with 90 ms IN/OUT bursts. Both a) P(S) at W, V(S) at X, P(T) at Y,
the processes were created at V(T) at Z, S and T initially 1
nearly the same time. The I N/OUT b) P(S) at W, V(T) at X, P(T) at Y,
of both processes can proceed in V(S) at Z, S initially 1 , and T
parallel. Which of the following initially 0
scheduling strategies will result in c) P(S) at W, V(T) at X, P(T) at Y,
the least CPU utilization (over a V(S) at Z, S and T initially 1
long period of time) for this d) P(S) at W, V(T) at X, P(T) at Y,
system? V(T) at Z, S initially 1, and T
a) First come first served initially 0
scheduling [GATE-2003]
b) Shortest remaining time first
scheduling Q.11 Which of the following will ensure
c) Static priority scheduling with that the output string never
different priorities for the two contains a substring of the form
processes 01𝑛 0 or 10𝑛 0 where n is odd?
d) Round robin scheduling with a a) P(S) at W, V(S) at X, P(T) at Y,
time quantum of 5 ms V(T) at Z, S and T initially 1
[GATE-2003] b) P(S) at W, V(T) at X, P(T) at Y,
V(S) at Z, S and T initially 1,
c) P(S) at W, V(S) at X, P(S) at Y, and the CPU Burst times given in
V(S) at Z, S initially 1 millisecond
d) P(S) at W, V(T) at X, P(S) at Y, Arrival Burst
Process
P(T) at Z, S and initially 1 Time Time
[GATE-2003] P1 0 5
P2 1 3
Q.12 Consider the following statements P3 2 3
with respect to user-level threads P4 4 1
and kernel-supported threads: What is the average turn-around
1. Context switch is faster with time for these processes with the
kernel-supported threads. pre-emptive shortest Remaining
2. for user-level threads, a system Processing Time First (SRPTF)
call can block the entire algorithm?
process. a) 5.50 b) 5.75
3. Kernel supported threads can c) 6.00 d) 6.25
be scheduled independently. [GATE-2004]
4. User level threads are
transparent to the kernel. Q.16 Consider two processes P1 and P2
Which of the above statements are accessing the shared variables X
true? and Y protected two binary
a) 2, 3 and 4 b) 2 and 3 semaphores Sx and Sy respectively,
c) 1 and 3 d) 1 and 2 both initialized to 1. P and V
[GATE-2004] denote the usual semaphore
operators, where P decrements the
Q.13 Which one of the following is NOT semaphore value, and V
shared by the threads of the same increments the semaphore value.
process? The pseudo-code of P1 and P2 is as
a) Stack follows:
b) Address Space
c) File Descriptor Table P1 P2
d) Message Queue While true While true
[GATE -2004] do{ do{
L1: ……… L3: ………
Q.14 A process executes the following
L2: ……… L4: ………
code
X=X+1; Y=Y+1;
for (i=0 ; i < n ; i + +)
Y=Y-1; X=Y-1;
fork ( );
The number of new processes V(Sx); V(Sy);
created is V(Sy); V(Sx);
a) n b) 2n - 1 In order to avoid deadlock, the
c) 2 n d) 2n+1 – 1 correct operators at L1, L2, L3 and
[GATE-2004] L4 are respectively
a) P(Sy ),P(Sx ),P(Sx ),P(Sy )
Q.15 Consider the following set of b) P(Sx ),P(Sy ),P(Sy ),P(Sx )
processes with the arrival times c) P(Sx ),P(Sx ),P(Sy ),P(Sy )
CPU Arrival
d) P(Sx ),P(Sy ),P(Sx ),P(Sy )
Proces time time
Priority
s require (hh:mm:ss
[GATE-2004] d )
10
Q.17 Suppose n processes, P1 , P2 ...., Pn P1 (highest 20 sec 0:00:05
share m identical resource units, )
which can be reserved and P2 9 10 sec 0:00:03
released one at a time. The 8
maximum resource requirement of P3 15 sec 0:00:00
(lowest)
process Pi is Si where Si>0. Which
one of the following is a sufficient
condition for ensuring that We have a choice of preemptive or
deadlock does not occur? non-preemptive scheduling. In
a) i,si m
preemptive scheduling, a late
b) i,si n
n
arriving higher priority process
c) si (m n) can preempt a currently running
i 1 process with lower priority. In
n
d) si (m*n) non-preemptive scheduling, a late–
i 1 arriving higher priority process
[GATE-2005] must wait for the currently
executing process to complete
Q.18 A user level process in Unix traps
the signal sent on a Ctrl- C input, before it can be scheduled on the
and has a signal handling routine processor. What are the
that saves appropriate files before turnaround times (time from
terminating the process. When a arrival till completion) of P2 using
Ctrl – C input is given to this preemptive and no preemptive
process, what is the mode in which scheduling respectively?
the signal handling routine
executes? a) 30 sec, 30 sec
a) kernel mode b) 30 sec 10sec
b) super user mode c) 42 sec 42 sec
c) privileged mode d) 30sec 42 sec
d) user mode [GATE -2005]
[GATE -2005]
Q.20 Two shared resources R 1 and R 2
Q.19 We wish to schedule three
are used by processes P1 and P2 .
processes P1, P2 and P3 on a
uniprocessor system. The Each process has a certain priority
priorities, CPU time requirements for accessing each resource Let Tij
and arrival times of the processes denote the priority of Pi for
are as shown below. accessing Rj A process Pi can
snatch a resource R k from process Q.23 The process state transition
Pj if Tik is greater than Tjk diagram of an operating system is
as give below.
Given the following:
I. T11 T21 II. T12 T22
III. T11 T21 IV. T12 T22
Which of the following conditions
ensures that P1 and P2 can never
deadlock?
a) (I) and (IV) b) (II) and (III)
c) (I) and (II) d)None
[GATE -2005]
EXPLANATIONS
Q.39 (c)
From the given code we get that P
(S) and V(S), decrement and
increment the value of semaphore
respectively. So, from the given
conditions we conclude that to
avoid mutual exclusion in the
value of Xb should be 1 and that of
Yb should be 0.
Q.40 (c)
A processor using pre-emptive
scheduling keeps the CPU and
releases it when it is switching to
waiting state which is indicated by
transition C and also a process in
blocked state can make transition
E while other process is in running
state.
Q.41 (a)
The given program initializes the
memory location X to 0 in the test
and set instruction and in the
function leaves CS( ).
This way there is no deadlock Q.46 (d)
occurred here and all the Statement I True: The shortest
processes are finished. job selects the waiting process
with the smallest execution time to
Q.43 (b) execute next. Shortest job next
Considering the options and their maximizes process throughput at
outcome, deadlock occurred in the number of processes
option (b): completed in a given time is the
P0 requires R0nR2, maximum. Thus, the average
P1 requires R20nR18, waiting time is for a process is
going on in this series—P8 will minimized. The disadvantage here
require R8nR10, is that it also permits process
P9 will requireR12nR10, starvation for the processes that
P10 will require R10nR12 and take long time to complete in a
P11 will require R10nR8. condition that short processes are
R10 is common requirement for continually added to the queue.
last 4 processes at a time and thus, Statement II True: Pre-emptive
it will lead to deadlock. algorithms are driven by the
Since, last 4 processes and prioritized computation. The
demanding the R10, deadlock is process with the highest priority is
unavoidable. the one that is currently using the
processor. If a process is currently
Q.44 (a) using the processor and a new
As per the methods provided in process with a higher priority
process 1 and process 2, the enters, the process on the
process 1 and process 2 processor should be removed and
cannot exist simultaneously in the returned to the ready list until its
critical section. So, when the priority becomes the highest-
process A is in the critical section, priority process.
process B is not and thus, the Statement III True: Round robin
condition of mutual exclusion is has a better response time than
satisfied but not progress. FCFS. Round robin calls for the
distribution of the processing time
Q.45 (a) equitably among all processes
P0 uses a semaphore. Hence, requesting the processor. Run
anything whose value is 1, P0 will process for one time slice, and then
print 'O'. After the release of S1 move to back of queue. Each
and S2, we observe that either P1 process gets equal share of the CPU.
or P2 will release P0 Most systems use some variant of
so that it prints '0' at least 2 times. this. All statements are true.
Therefore, it is concluded that
neither P1 nor P2 will go, it is the P0 Q.47 (c)
that prints '0' 2 times at least. Process switching involves mode
switch. Context switching can
occur only in kernel mode. t1 < t2
Q.48 (d) Q.53 (b)
As if CPU temperature is high, the Acquire Lock (L)
computer immediately shut down. Initial value of L = 0
{
Q.49 (c) While (Fetch_And_add (L,
Threads share address space of 1))
Process. Virtually memory is {
concerned with processes not with L = 1;
Threads. }
}
Q.50 (a) Release Lock (L)
Waiting time of P0 =5-1 = 4 {
Waiting time of P1 =1-1=0 L = 0;
Waiting time of P2 =13-2=11 }
Average waiting time When P1 process executes Acquire
4 0 11 15
5
lock, after executing it, value of L=
3 3 1;
[∵ P1 Fails the while loop
Q.51 (c) condition because Fetch_And_Add
A process executes the code and instruction return 0 and it sets the
works as follows: value of L=1]
The number of child processes Now, there is a context switch and
created 2n 1 23 1 still realase lock (L) produce hasn't
=8–1=7 been executed.
Where, n=3∵ 3 fork ( ) are Now, another process P2 executes
executing. the acquire lock (L), it will execute
the while loop indefinite period of
Q.52 (c) time.
Process Arrival Time units Now, suppose at this point i.e.,
time required While (Fetch_And_Add (L, 1))
P1 0 5
{
P2 1 7
P3 3 4
→ L = 1;
FCFS: }
0 5 12 16 Process P2 context switch occurs.
Order P1→ P2→ P3 Now, control again comes to P1 it
Round robin here, not P2 because will execute realease lock
in the ready queue P2 comes later procedure and the value of L
than P3. becomes 0.
Now, lock is free.
Now, after this suppose again
0 2 4 6 8 10 11 13 15 16 context switch occurs, controls
Here, not P3 because in the ready return to P2. P2 will again set the
queue comes first than P3. value of L=l Now, P2 will again
Order P1→ P3→ P2 executing the while loop indefinite
amount of time.
At this instance lock is free; even variable in the processer.
then P2 can't get it because value (Acceptable)
of lock is not zero. (c) X : P(b) P(a) P(c)
Any other-process will also blocks Y : P(c) P(b) P(d)
now in the infinite while loop, even Z: P (a) P(c) P (d)
the lock is free. X Y Z
This implementation fails as L can P(b) P(c) P(a)
take on a non-zero value when the P(a) P(b) P(c)
lock is actually available. P(c) P(d) P(d)
The sequence of variable P{b) and
Q.54 (b) P(c) are reverse and opposite [i.e.,
Three concurrent processes X, Y P(b) P(c) P(a) and P(a) P(b) P(c)]
and Z execute three different code So, deadlock may occurs in X and Y
segments that access and update respectively (Not Acceptable)
certain shared variables. (d) X : P(a) P(b) P(c)
Processes Y : P(c) P(b) P(d)
X Y Z Z: P(c) P (d) P (a)
P(a) P(b) P(c) X Y Z
P(b) P(c) P(d) P(a) P(c) P(c)
P(c) P(d) P(a) P(b) P(b) P(d)
(a) X : P(a) P(b) P(c) P(c) P(d) P(a)
Y : P(b) P(c) P(d) The sequence of variable P(c) and
Z : P(c) P (d) P (a) P (a) are opposite in Z and X. So,
Suppose X first executes P(a) and deadlock may occur (Not
P(b) and then switches to process Acceptable) Hence, the answer is
Z. where P(c) and P(d) are (b).
executed and wait for P(a). Then
again process switches to X and Q.55 (b)
then wait for P(c). The scheduling algorithm works as
∴ Process X is waiting for C which round robin with quantum time
is occupied by Z and Z is waiting equals to T. After a process's turn
for a is occupied by process X. comes and it has executed for T
So neither can execute and units, its waiting time becomes
deadlock occurs. (Not Acceptable) least and its turn comes again after
(b) X : P(b) P(a) P(c) every other process has got the
Y : P(b) P(c) p(d) token for T units.
Z: P (a) P(c) P (d)
X Y Z Q.56 (d)
P(b) P(b) P(a) Each of the processes W and X
P(a) P(c) P(c) reads x from memory and
P(c) P(d) P(d) increment x by 1. Each of the
Execution can be carried out in a processes Y and Z reads x from c.
proper way without deadlock Memory, and decrement by 2.
occurrence and no wait for any
1. Start with X and perform P(S) by process X. There is no sequence
then S = 1 read X = 0 x = X + 1 = of operation in which the value of
1 R or S overlaps. Both processes
2. Then Y will perform P(S) then S execute one after another.
= 0 read X - 0 x = x -2 = -2 then So, option (c) is correct.
store x. V(S), S =1 Option (d) suppose first process X
3. Then Z will perform P(S) then S executes it sets R = 1 and then
= 0, read x = -2x = x- 2 = -4 then waits for S. Now after that process
store X, V(S).S = 1. Y executes. It first sets S = 1 and.
4. Then x will store x. V(S), S=2, decrement R = 0. It comes again
X= 1 and. then again sets S = 1(/'.e., it
5. Then W will perform P(S), S =1, overlaps the value of S) and then
read x = 1 again wait for- R.. Clearly hence
x = x + 1 = 2, store x, V(S), S =2, one iteration of process X is lost
x=2 due to overlapping of value of S,
Hence, answer is option (d). and after n -1 iteration process X
will be stuck.
Q.57 (c) So option (d) is wrong.
Options (a) suppose process X
executes Exit X then it will wait for Q.58 (c)
R, and then process Y executes (A)The producer will be able to
Entry Y then it will wait for S. add an item to the buffer, but the
Since, initially both binary consumer can never consume if
semaphores are 0, no one will given statement is false, because
increment it and both processes once producer produces an item
will be stuck up in a deadlock. and places in buffer, the next turn
Option (a) is incorrect. to execute can be given to
Option (b) Here if process X consumer ( ). [The value of s = 1
executes for n times repeatedly it and n=1]. So consumer will be
will set both semaphores to 1 definitely able to consume it by
(since only two values are performing successful down
possible) and after that process y operations on s and n.
executes. First time it passes the (B)The consumer will remove no
Entry Y and makes both more than one item from the
semaphores to 0. buffer.
And on second time it finds both Given statement is false as if p( )
semaphores to 0 and cannot pass produces and adds to buffer, (c)
the Entry Y barrier. Hence it will will consume the added item, this
get stuck. sequence of alteration (p and c)
So, option b is wrong. will always make consumer to
Option (c) Considering any remove items from buffer.
sequence of operation of process X This statement would have been
and process Y, first process X will true if it was said that the
wait for S which is increment by consumer will remove no more
process Y and then . Process Y than one item from the buffer one
waits for R which is incremented after the other. (at a time).
(C)Dead lock occurs if the Q.60 (7.2)
consumer succeeds in acquiring P1 P2 P3
semaphore‘s’ when the buffer is
empty. Given statement is true as A B A C E D
when buffer is empty initially if
consumer gets the turn to execute. 0 3 5 8 12 15 21
(D)Even if the starting value for Average Turn Around time
the semaphore ‘n’ becomes 1, =(8-0)+(5-3)+(12-5)+(21-7)+(15-
there will be invalid execution of 10)/5
consumer on buffer empty = 36/5 = 7.2ms
condition, which should not
happen. So statement is false. Q.61 (1000) There are three processes
A, B and C that run in round robin
Q.59 (d) manner with time slice of 50 ms.
User threads are supported above Processes start at 0, 5 & 10
the kernel and a managed without miliseconds.
kernel support. The thread The processes are executed in
function library to implement user below order A, B, C, A
level threads usually runs on top of 50 + 50 + 50 + 50 (200 ms passed)
the system in user mode. Thus Now A has completed 100 ms of
these threads with in a process are computations and goes for I/O
invisible to the operating system. now
Since the kernel is unaware of the B, C, B, C, B, C
existence of such threads; when 50+50+50+50+50+50(300ms
passed)
one user level thread is blocked in
C goes for i/ o at 500ms and it
the kernel all other threads of its
needs 500ms to finish the IO.
process are blocked. So options (a)
So C would complete its first IO at
and (b) are true (c) The OS is
1000 ms
aware of kernel level threads.
Kernel threads are scheduled by
Q.62 (5.5)
the OS’s scheduling algorithms and
The Gantt chart for SRTF
require a “lightweight” context
scheduling algorithm is as follows:
switch to switch between (that is,
registers, PC and SP must be P1 P2 P3 P4 P1
changed, but the memory context 0 2 6 12 17
remains the same among kernel 27
threads in the (same process). Average waiting time =
User level threads are much faster (15+0+3+4) / 4 = 22/4 = 5.5
to switch between as there is not Q.63 (b)
context switch (d) False Kernel REQ1
level threads within the same Once P0 is allocated with (0, 0, 2),
process share code section, data the status of the system will be as
section and other operating follows
system resources such as open
files and signals.
Allocation Max Need Available situation P1 and P2 can continue
XYZ XYZ XYZ XYZ as they have 2 resources each
003 843 840 320 P1 2
320 620 300 P2 2
211 333 122 P3 1
P4 1
With available (3, 2, 0) only P1 can
be served. Once P1 is executed, Q.66 (d)
available will be (6, 4, 0), with (6, If Ist is followed, then hold and
4, 0) we can’t serve either P0 or wait will never happen. II, III and
P2. Hence there is no safe IV are similar. If any of these is
sequence. Hence REQ1 can’t be followed, cyclic wait will not be
permitted. possible.
REQ2
Once 1 P is allocated with (2, 0, 0), Q.67 (12)
the status of the system will be as Periods of T1, T2 and T3 are 3ms,
follows 7ms and 20ms
Since priority is inverse of period,
Allocation Max Need Available T1 is the highest priority task, then
XYZ XYZ XYZ XYZ T2 and finally T3
001 843 840 122 Every instance of T1 requires 1ms,
520 620 100 that of T2 requires 2ms and that of
211 333 122 T3 requires 4ms
With available (1, 2, 2), we can Initially all T1, T2 and T3 are ready
serve either P1 or P2. to get processor, T1 is preferred
If we serve P1 then the safe Second instances of T1, T2, and T3
sequence is P1, P2, P0. If we serve shall arrive at 3, 7, and 20
P2 then the safe sequence is P2, respectively.
P1, P0. As true is at least one safe Third instance of T1, T2 and T3
sequence we can permit REQ2. shall arrive at 6, 14, and 49
respectively.
Q.64 (7) Time-Interval Tasks
If 6 resources are there then it may 0-1 T1
be possible that all three process 1-2 T2
have 2 resources and waiting for 1 2-3 T2
more resource. Therefore, all of 3-4 T1
them will have to wait indefinitely. [Second Instance of T1 arrives]
If 7 resources are there, then 4-5 T3
atleast one must have 3 resources 5-6 T3
so deadlock can never occur. 6-7 T1
[Third Instance of T1 arrives]
Q.65 (4)
It seems to be wrong question [Therefore T3 is preempted]
in GATE exam. Below seems to be 7-8 T2
the worst case situation. In below [Second instance of T2 arrives]
8-9 T2
9-10 T1 conditions to be satisfied for
[Fourth Instance of T1 arrives] deadlock to happen. Hence,
10-11 T3 answer is A.
11-12 T3
[First Instance of T3 completed] Q.71 (a)
It satisfies the mutual exclusion,
Q.68 (d) since only one process can be in
The size of ready queue doesn't the critical section at any time.
depend on number of processes. A
single processor system may have Q.72 (c)
a large number of processes The given Qution for two process
waiting in ready queue. synchronization using “turn”
variable satisfies the only mutual
Q.69 (c) exclusion and bounded waiting but
Turnaround time is the total time progress is violated.
taken between the submission of a Consider that Process”0” executed
program/process/thread/task its critical section and made
(Linux) for execution and the turn=1 and Process”0” wants to
return of the complete output to execute the critical section for the
the customer/user. 2nd time,
Turnaround Time = Completion Process”0” has to wait indefinitely
Time - Arrival Time. for Process”1” to start, which will
FCFS = First Come First Serve (A, make turn=0.
B, C, D); Average Turnaround Now we can say that Progress
time= 7.25 condition is failed, since Critical
SJF = Non-preemptive Shortest Job Section is free and Process “0”
First (A, B, D, C); Average wants to enter Critical Section and
Turnaround time= 6.75 it can enter only if Process “1”
SRT=Shortest Remaining Time turns up.
(A(3), B(1),C(4),D(2),B(5));
Average Turnaround time= 6.25 Q.73 (7)
RR = S = -20 + 12 = -8
Round Robin with Quantum value 2 If initial value of S = 8 then 20 P(S)
(A(2),B(2),A(1),C(2),B(2),D(2),C(2), operations will succeed.
B(2) As want to block at least one P(S)
Average Turnaround time= 8.25 operation by keeping “S” the
largest initial value.
Q.70 (a) If we keep initial value of S=7, then
When both processes try to enter 19 P(S) operations will succeed
critical section simultaneously, and only 20th P(S) operation will
both are allowed to do so since get blocked.
both shared variables varP and The largest initial value of S for
varQ are true. So, clearly there is which at least one P(S) operation
NO mutual exclusion. Also, deadlock remains blocked is 7.
is prevented because mutual
exclusion is one of the four
Q.74 (a) Q.77 (3.0)
Facts about scheduling algorithms Using preemptive SRTF algorithm
is Gantt chart will be,
1) FCFS can cause long waiting
times, especially when the first
job takes too much CPU time.
2) Both SJF and Shortest
Remaining time first
algorithms may cause Turnaround time Waiting time
starvation. Consider a situation P1 12 0 12
when long process is there in P2 6 3 3
ready queue and shorter P3 17 5 12
processes keep coming.
3) If time quantum for Round P4 8 6 2
Robin scheduling is very large, P1 12 7 5
then it behaves same as FCFS P2 3 3 0
scheduling.
P3 12 5 7
4) SJF is optimal in terms of
average waiting time for a P4 2 2 0
given set of processes. SJF gives Average Waiting Time
minimum average waiting 5070
time, but problems with SJF is 3.0
4
how to know/predict time of
next job. Q.78 (c)
There are ‘x’ number of threads
Q.75 (8.25) and ‘y’ number of locks
Pre-emptive Shortest Remaining Now, considering each option,
time first scheduling, i.e. that If there is 1 threads and two locks
processes will be scheduled on the then there won’t be situation of
CPU which will be having least deadlock.
remaining burst time (required Similarly if there is only 1 lock ,
time at the CPU). there will be no deadlock
The processes are scheduled and situation
executed as given in the below But when there are two processes
Gantt chart. and two threads, deadlock
P1 P2 P3 P2 P4 P1 situation can occur because both
0 3 7 8 10 13 20 the process can acquire one lock
and may demand another lock
Q.76 (d ) which arises deadlock.
Generally every thread of a
process have their own PC and Q.79 (b)
stack. Both heap and global All the threads share address
variables are shared by every space but other entities like, stack,
thread of a process PC resisters are not shared and
every thread will have its own.
Q.80 (29)
P1 P4 P2 P4 P1 P3 P5
0 2 5 33 40 43 51 67
145
Average waiting time 29
5
Q.81 (b)
Pro Current Max. Remaining Current
cess Allocatio Requireme need availabl
n nt e
P1 3 7 4 9-7=2
P2 1 6 5 5
P3 3 5 2 8
9
Safe sequence ⇒ P3 →P1→P2
Safe and not deadlocked
Q.82 2
P1 P2 P3
| | |
| No deadlock
Maximum each process can
request for 2 resources so, that
there will not be any deadlock,
because we have only 4 resource
available.
So, K value is ‘2’.
Q.83 (a)
Q.13 Least Recently Used (LRU) page Q.16 The essential content(s) in each
replacement policy is a practical entry of a page table is/are
approximation to optimal page a) virtual page number
replacement. For the above b) page frame number
reference string, how many more c) Both virtual page number and
page faults occur with LRU than page frame number
with the optimal page replacement d) access right information
policy? [GATE-2009]
a) Zero b) 1
c) 2 d) 3 Q.17 A multilevel page table is
[GATE-2007] preferred in comparison to a single
level page table for translating
Q.14 A processor uses 36 bit physical virtual address to physical address
addresses and 32 bit virtual because
addresses, with a page frame size a) it reduces the memory access
of 4 Kbyte. Each page table entry is time to read or write a memory
of size 4 byte. A three level page location
b) it helps to reduce the size of register stores the base address of 1st
page table needed to level page table (T1), which occupies
implement the virtual address exactly one page, each entry of T1 stores
space of a process the base address of a page of the second-
c) it is required by the translation level page table T2, each entry of T2
look-aside buffer stores the base address of a page of third
d) it helps to reduce the number level page level (T3), each entry of T3
of page faults in page stores a page tableentry (PTE) the PTE is
replacement algorithms. 32 bit in size. The process or used in the
[GATE-2009] computer has a 1 MB 16-way set
associative virtually indexed tagged
Q.18 A system uses FIFO policy for page cache. Cache block size is 64 bytes.
replacement. It has 4 page frames
with no pages loaded to begin Q.20 What is the size of a page in KB in
with. The system first accesses 100 this computer?
distinct pages in some order and a) 2 b) 4
then accesses the same 100 pages c) 8 d) 16
but now in the reverse order. How [GATE-2013]
many page faults will occur?
a) 196 b) 192 Q.21 What is the minimum number of
c) 197 d) 195 page colors needed to guarantee
[GATE-2010] that no two synonyms map to
different sets in the processor
Q.19 Consider the virtual page cache of this computer?
reference string: 1, 2, 3, 2, 4, 1, 3, 2, a) 2 b) 4
4, 1 c) 8 d) 16
On a demand paged virtual [GATE-2013]
memory system running on a
computer system that has main Q.22 Assume that there are 3 page
memory size of 3 page frames frames which are initially empty. If
which are initially empty. Let LRU the page reference string is 1, 2, 3,
FIFO and PTIMAL denote the 4, 2, 1, 5, 3, 2, 4, 6 the number of
number of page faults under the page faults using the optimal page
corresponding page replacement replacement policy is ___.
policy. Then, [GATE–2014]
a) OPTIMAL < LRU < FIFO
b) OPTIMAL < FIFO < LRU Q.23 A computer has twenty physical
c) OPTIMAL = LRU page frames which contain
d) OPTIMAL = FIFO numbered 101 through 120. Now a
[GATE-2012] program accesses the pages
numbered 1, 2, ..… 100 in that
Statements for Linked Answer order, and repeats the sequence
Questions Q.20 & Q.21: THRICE. Which one of the
A computer uses 46-bit virtual address, following page replacement
32-bit physical address ree-level paged policies experience the same
table organization, the page table base number of page faults as the
optimal page replacement policy with respect to page replacement
for this program? policies First-In-First Out (FIFO)
a) Least-recently-used and Least Recently Used (LRU)?
b) First-in-First-out a) Both incur the same number of
c) Last-in-First-out page faults
d) Most-recently-used b) FIFO incurs 2 more page faults
[GATE–2014] than LRU
c) LRU incurs 2 more page faults
Q.24 A system uses 3 page frames for than FIFO
storing process pages in main d) FIFO incurs 1 more page faults
memory. It uses the Least Recently than LRU
Used [LRU] page replacement [GATE–2015]
policy. Assume that all the page
frames are initially empty. What is Q.28 A computer system implements a
the total number of page faults 40-bit virtual address, page size of
______________that will occur which 8 kilobytes, and a 128- entry
processing the page reference translation look-aside buffer (TLB)
string given below? 4, 7, 6, 1, 7, 6, organized into 32 sets each having
1, 2, 7, 2 four ways. Assume that the TLB
[GATE–2014] tag does not store any process id.
The minimum length of the TLB
Q.25 Consider a paging hardware with a tag in bits is _________.
TLB. Assume that the entire page [GATE–2015]
table and all the pages are in the
physical memory. It takes 10 Q.29 Consider six memory partitions of
milliseconds to search the TLB and sizes 200 KB, 400 KB, 600 KB, 500
80 milliseconds to access the KB, 300 KB and 250 KB, where KB
physical memory. If the TLB hit refers to kilobyte. These partitions
ratio is 0.6, the effective memory need to be allotted to four
access time (in milliseconds) is processes of sizes 357 KB, 210KB,
_______. 468 KB and 491 KB in that order. If
[GATE–2014] the best fit algorithm is used,
which partitions are NOT allotted
Q.26 Consider a system with byte- to any process?
addressable memory, 32 bit logical a) 200KB and 300 KB
addresses, 4 kilobyte page size and b)200KB and 250 KB
page table entries of 4 bytes each. c)250KB and 300 KB
The size of the page table in the d)300KB and 400 KB
system in megabytes is ___________. [GATE–2015]
[GATE–2015]
Q.30 Consider a computer system with
Q.27 Consider a main memory with five 40-bit virtual addressing and page
page frames and the following size of sixteen kilobytes. If the
sequence of page references: 3, 8, computer system has a one-level
2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3. page table per process and each
Which one of the following is true page table entry requires 48 bits,
then the size of the per-process Q.33 Consider a machine with a byte
page table is _____ megabytes. addressable main memory of 232
[GATE–2016] bytes divided into blocks of size 32
bytes. Assume that a direct
Q.31 Consider a computer system with mapped cache having 512 cache
ten physical page frames. The lines is used with this machine.
system is provided with an access The size of the tag filed in bits is
sequence (a1, a2,…, a20, a1, a2,… ___.
a20), where each ai is a distinct [GATE–2017]
virtual page number. The
difference in the number of page Q.34 Consider a 2-way set associative
faults between the last-in-first-out cache with 256 blocks and uses
page replacement policy and the LRU replacement, initially the
optimal page replacement policy is cache is empty. Conflict misses are
______. those misses which occur due to
[GATE–2016] contention of multiple blocks for
the same cache set. Compulsory
Q.32 In which one of the following page misses occur due to first time
replacement algorithms it is access to the block. The following
possible for the page fault rate to sequence of accesses to memory
increase even when the number of blocks (0,128,256,128,0,128,256,
allocated frames increases? 128,1,129,257,129,1,129,257,129)
a) LRU (Least Recently Used) is repeated 10 times . The number
b)OPT (Optimal Page of conflict misses experienced by
Replacement) the cache is ___.
c) MRU (Most Recently Used) [GATE–2017]
d) FIFO (First In First Out)
[GATE–2016]
ANSWER KEY:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(c) (d) (c) (c) (d) (c) (a) (d) (c) (c) (b) (a) (c) (d) (a)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
(b) (b) (a) (b) (c) (c) 7 (d) 6 122 4 (a) 22 (a) 384
31 32 33 34
1 (d) 18 78
EXPLANATIONS
Q.15 (a)
In Belady's anomaly, if number of
Optimal page replacement policy frames are increased the number
replaces the page which will not be of page faults increases. This
used for longest time. behaviour found only with FIFO.
Total number of page faults = 7 The First In, First out (FIFO) page
replacement algorithm is a low-
Q.13 (c) overhead algorithm. In FIFO, the
LRU replaces the page which is operating system keeps track of all
used least recently. the pages in memory in a queue.
Page frames The queue is managed in a way
Total number of page faults = 9 that the most recent arrival is
Therefore, an increase of 2 is there placed at the back, and the earliest
(97) in LRU than in optimal. arrival in front. T the time of page
replacement, oldest page is First In, First out (FIFO) page
selected to get replaced. Practical replacement algorithm is a low-
implementation of FIFO is not very overhead algorithm. In FIFO, the
good as the algorithm experiences
operating system keeps track of all
Belady's anomaly. In FIFO when
the number of frames increases the pages in memory in a queue. The
then, the number of page faults queue is managed in a way that the
also increases and this behaviour most recent arrival is placed at the
is found by Belady's anomaly. back, and the earliest arrival in front.
Thus, FIFO have this Belady's T the time of page replacement, oldest
anomaly, e.g., in FIFO for . three page is selected to get replaced.
frames the reference string 1,2, 3,
Practical implementation of FIFO is
4, 1,2, 5, 1,2, 3,4, 5 There are 9
page faults and for four frames for not very good as the algorithm
the reference string there will be experiences Belady's anomaly. Given
10 faults. are 4 page frames. The 100 pages are
accessed in some order→ 1 to pages
Q.16 (b) will get 100 faults. Now, after the
A page table is the data structure pages are accessed, they are to be
used to store the mapping
accessed in reverse order. But in
between virtual addresses and
physical addresses. A page table is reverse, there won't be any fault for
used by a Virtual memory system page numbers 100, 99, 98, 97.
in a computer operating system. Therefore, all page frames are
Virtual addresses are the occupied. Now, for remaining 96
addresses which are unique to the accesses, 96 faults would occur.
accessing process while physical
addresses are the addresses that Total 100 (Direct access)+ 96
are unique to the CPU, i.e., RAM. (Reverse access) = 196
Page frame number is essential Alternate method
content in each of the page table. Fault for n pages = 2n -4
Virtual page number may not be So, for 100 pages = 2 × 100
store entirely in the page table and – 4 =196
thus, cannot be considered as the
essential content. Q.19 (b)
Reference string:
Q.17 (b) 1, 2, 3, 2, 4, 1, 3, 2, 4, 1
As we know that the, use of multilevel 3 page frames.
page table reduces the size of the FIFO
page table needed to implement the There are 6 page faults.
virtual address space of a process.
Q.18 (a)
Let’s understand the concept of FIFO
page replacement algorithm. The
Optimal As the page size is 213 bytes, we
divide cache size by page a size
and group 16 pages in one set
No. of pages in cache = 1MB/8KB =
128 pages
No. of sets in cache =128/16 = 8
sets
There are 5 page faults. So minimum use need 8 colors for
LRU mapping.
Q.22 (7)
Given three page frames.
Reference string is 1, 2, 3, 4, 2, 1, 5,
3, 2, 4, 6 Initially, there are three
page faults and entries are 1 2 3
There are 9 page faults. Page 4 causes a page fault and
Hence, optimal < FIFO < LRU replaces 3 (3 is the longest distant
in future), entries become 1 2 4
Q.20 (c) Total page faults = 3+1 = 4
Let the page size 2x byte Pages 2 and 1 don't cause any
Then the page off set = x bites. fault.
46,x x 5 causes a page fault and replaces
1, entries become 5 2 4
As mentioned, first level page table
Total page faults = 4 + 1 = 5
is contained in one page, each page
3 causes a page fault and replaces
table entry is 32-bit.
1, entries become 3 2 4
The size of T3 is =246 X 22/2x =
Total page faults = 5 + 1 = 6
246+2-x [∴PTE -32 bit, 3 B = 22B]
3, 2 and 4 don't cause any page
The size of T2 is = 246+2-x X 22/ 2x
fault.
= 246+4-x
6 causes a page fault.
The size of T1 is = 246+4-x X 22/ 22
Total page faults = 6 + 1 = 7
= 246+6-3x
Q.23 (d)
The optimal page replacement
algorithm swaps out the page
whose next use will occur farthest
in the future. In the given question,
the computer has 20 page frames
∴ 46 = 6 -3x –x ⟹ x= 13 [T1 and initially page frames are filled
exactly occupies of page] with pages numbered from 101 to
That means, page size is of 13 bit 120.
or pae size = 213 bytes = 8KB. Then program accesses the pages
numbered 1, 2, …, 100 in that
Q.21 (c) order, and repeats the access
sequence THRICE. The first 20
accesses to pages from 1 to 20
would definitely cause page fault. Q.27 (a)
When 21st is accessed, there is 3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3
another page fault. The page In both FIFO and LRU, we get
swapped out would be 20 because following after considering 3, 8, 2,
20 is going to be accessed farthest 3, 9, 1, 3 8 2 9 1
in future. When 22nd is accessed, FIFO
21st is going to go out as it is going 6 replaces 3
to be the farthest in future. The 82916
above optimal page replacement 3 replaces 8
algorithm actually works as most 29163
recently used in this case. As a side 8 replaces 2
note, the first 100 would cause 100 91638
page faults, next 100 would cause 2 replaces 9
81 page faults (1 to 19 would 16382
never be removed), the last 100 No more page faults
would also cause 81 page faults. LRU
6 replaces 8
Q.24 (6) 32916
Page reference string is 8 replaces 2
4, 7, 6, 1, 7, 6, 1, 2, 7, 2 39168
2 replaces 1
39682
1 replaces 8
39621
3.2 INTERRUPTS
I/O is a major factor in system The simplest form of disk scheduling is,
performance. It places heavy demands on first-come, first-serve (FCFS). This
the CPU to execute device-driver code and
algorithm is intrinsically fair, but it
to schedule processes fairly and efficiently generally does not provide the fastest
as they block and unblock. service. Consider, a disk queue with
requests for I/O to blocks the fastest
3.6.1 Disk Scheduling service.
98, 183, 37, 122, 14, 124, 65, 67 in that
One of the responsibilities of the operating order. If the disk head is initially at cylinder
system is to use the hardware efficiently. 53, it will first move from 53, to 98, then to
For the disk drives, this means having a 183, 37, 122, 14, 124 65 and finally to 67,
fast access time and disk bandwidth. The for a total head movement of 640
access time has two major components. cylinders. The schedule is diagrammed in
i) The seek time is the time for the disk the following figure.
arm to move heads to the cylinder The problem with this schedule is
containing rotate the desired sector. illustrated by the wild swing from 122 to
The rotational latency is the additional 14 and
time waiting for the disk to rotate the
desired sector to the disk head.
It is reasonable to service all the requests In the SCAN algorithm, the disk arm starts
close to the current head position, before at one end of the disk, and moves toward
moving the head far away to service other the other end, servicing requests as it
requests. This assumption is the basis for reaches each cylinder, until it gets to the
the shortest-seek-time-first(SSTF) other end of the disk. At the other end, the
algorithm. direction of head movement is reversed,
For our example request queue, the closest and servicing continues. The head
request to the initial head position (53) is continuously scans back and forth across
at cylinder 65. Once we are at cylinder 65, the disk.
the next closet request is at cylinder 67. Before applying SCAN to schedule and
From there, the request at cylinder 37 is requests on cylinders 98, 183, 37, 122, 14,
closer than 98, so 37 is served next. 124, 65, and 67, it is required to know the
Continuing, we service the request at direction of head movement, in addition to
cylinder 14, then 98, 122, 124, and finally the head's current position (53). If the disk
at 183 (Figure). This scheduling method arm is moving toward 0, the head will
results in a total head movement of only service 37 and then 14. At cylinder 0, the
236 cylinders, little more than one-third of arm will reverse and will move toward the
the distance needed for FCFS scheduling. other end of the disk, servicing the
This algorithm gives a substantial requests at 65, 67, 98, 122, 124, and 183. If
improvement in performance. a request arrives in the queue just in front
SSTF scheduling is essentially a form of of the head, it will be serviced almost
shortest-job-first (SJF) scheduling, and, immediately; a request arriving just
like SJF scheduling, it may cause starvation behind the head will have to wait until the
of some requests. arm moves to the end of the disk, reverses
Although the SSTF algorithm is a direction, and comes back.
substantial improvement over the FCFS The SCAN algorithm is sometimes called
algorithm, it is not optimal. In the example, the elevator algorithm, since the disk arm
we can do better by moving the head from behaves just like an elevator in a building,
53 to 37, even though the latter is not first servicing all the requests going up and
closet, and then to 14, before turning then reversing to service requests the
around to service 65, 67, 98, 122, 124 and other way.
183. This strategy reduces the total head
movement to 208 cylinders.
Q.1 Which of the following does not disk with 100 tracks is given: 45,
interrupt a running process? 20, 90, 10, 50, 60, 80, 25, 70.
a) A device Assume that the initial position of
b) Timer the R/W head is on track 50. The
c) Scheduler process additional distance that will be
d) Power failure traversed by the R/W head when
[GATE -2001] the Shortest Seek Time First
(SSTF) algorithm is used
Q.2 Consider an operating system compared to the SCAN (Elevator)
capable of loading and executing a algorithm(assuming that SCAN
single sequential user process at algorithm moves towards 100
a time. The disk head scheduling when it starts execution) is
algorithm used is First Come First _________ tracks.
Served (FCFS). If FCFS is replaced [GATE–2015]
by Shortest Seek Time First
(SSTF), claimed by the vendor to Q.5 Consider a disk queue with
give 50% better benchmark requests for I/O to blocks on
results, what is the expected cylinders 47, 38, 121, 191, 87, 11,
improvement in the IN/OUT 92, 10.
performance of user programs? The C-LOOK scheduling algorithm
a) 50% b) 40% is used. The head is initially at
c) 25% d) 0% cylinder number 63, moving
[GATE-2004] towards larger cylinder numbers
on its servicing pass. The cylinders
Q.3 Consider a disk system with 100 are numbered from 0 to 199.
cylinders. The requests to access The total head movement (in
the cylinders occur in following number of cylinders) incurred
sequence while servicing these requests is
4, 34, 10, 7, 19, 73, 2, 15, 6, 20 [GATE–2016]
Assuming that the head is
currently at cylinder 50, what is
the time taken to satisfy all
requests, if it takes 1 ms to move
from one cylinder to adjacent one
and shortest seek time first policy
is used?
a) 95 ms b) 119 ms
c) 233 ms d) 276 ms
[GATE-2009]
EXPLANATIONS
Three major methods of allocating disk Linked allocation solves all problems of
space are in wide use: contiguous, lined, contiguous allocation. With linked
and indexed. Each method has its allocation, each file is a linked list of disk
advantages and disadvantages. blocks; the disk blocks may be scattered
anywhere on the disk. To create a new file,
4.6.1 Contiguous Allocation we simply create a new entry in the
directory. With linked allocation, each
The contiguous allocation method directory entry has a pointer to the first,
requires each file to occupy a set of disk blocks of the file. The pointer is
contiguous blocks on the disk. Disk initialized to nil (the end – of- list pointer
addresses define a linear ordering on the value) to signify an empty file. A write to
disk. the file causes free blocks to be found via
the free-space management system, and
this new block is then written to, and is
linked to the end of the file. To read a file,
we simply read blocks by following the
pointers from block to block. There is no
external fragmentation with linked
allocation.
4.7.3 Grouping
EXPLANATIONS
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.6 (99.6)
Number of entries in the FAT = Disk
Capacity/Block size= 108/103 = 105
Total space consumed by FAT = 105
* 4 B = 0.4 * 106 B
Maximum size of file that can be
stored=100*106–0.4*106=99.6*106 B
Q.7 (d)
Linked and indexed allocated are
non contiguous so, they will not
suffer from external fragmentation
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
ASSIGNMENT QUESTIONS
Q.4 Page fault occurs when Q.9 The only state transition that is
a) The page is corrupted by initiated by the user process itself is
application software a) Block b) dispatch
b) The page is main memory c) Wakeup d) None of the above
c) The page is not in main memory
d) One tries to divide a number by 0 Q.10 Working set (t, k) at an instant of
time, t, is the set of
Q.5 Overlay is a) K future reference that the
a) A part of the operating system operating system will make
b) A specific memory location b) Future reference that the
c) A single contiguous memory that operating system will make in
used in the olden days for the next ‘k’ time units
Running large programs by c) K reference with high frequency
swapping. d) Pages that have been referenced
d) Overloading the system with in the last k time units
many user files
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.11 Fragmentation is c) the portion of the main memory
a) dividing the secondary memory which can be accessed only by
into equal sized fragments one process at a time
b) dividing the main memory into d) None of the above
equal-sized fragments
Q.17 Kernel is
c) Fragments of memory words
a) Considered as the critical part of
used in a page
the operating system
d) Fragments of memory words
b) The software which monitors
unused in a page
the operating system
Q.12 Which of the following are real-time c) The set of primitive function
upon which the rest of operating
systems?
system functions are built up.
a) An on-line railway reservation
d) None of the above
system
b) A process control system
Q.18 With a single resource, deadlock
c) Aircraft control system
occurs
d) Payroll processing system
a) If there are more than two
Q.13 Dijkstra’s banking algorithm in a processes competing for that
resource
operating system solves the
problem of b) If there are only two processes
competing for that resource
a) Deadlock avoidance
b) Deadlock recovery c) If there is a single process
competing for that resource
c) Mutual exclusion
d) None of the above
d) Context switching
Q.19 Necessary conditions for deadlock
Q.14 In page memory systems, if the page are
size is increased, then the internal a) Non-pre-emption & circular wait
fragmentation generally b) Mutual exclusion & partial
a) Becomes less allocation
b) Becomes more c) Both (a) and (b)
c) Remains constant d) None of the above
d)none of the above
Q.20 In a time-sharing operating system,
Q.15 An operating system contains 3 user when the time slot given to a
processes each requiring 2 units of process is completed, the process
resource R. The minimum number goes from the RUNNING state to the
of units of R such that no deadlock a) BLOCKED state
will ever occur is b) READY state
a) 3 b)4 c) SUSPENDED state
c) 5 d) 6 d) TERMINATED state
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.22 Supervisor call b) Among process that share
a) Is a call made by the supervisor resource
of the system? c) Among process that do not use
b) Is a call with control functions? the same resource
c) Are privileged calls that are used d) None of the above
to perform resource management
functions, which are controlled Q.28 Sector interleaving in disks is done by
by the operating system. a) The disk manufacturer
d) Is a call made by someone b) The disk controller code
working in root directory? c) The operating system
d) None of the above
Q.23 Semaphores are used to solve the
problem of Q.29 Memory protection is of no use in a
a) Race condition a) Single user system
b) Process synchronization b) Non-multiprogramming system
c) Mutual exclusion c) Non-multitasking system
d) None of the above d) None of the above
Q.24 If the property of locality of Q.30 Some computer system support dual
reference is well pronounced in a mode operation-the user mode and
program the supervisor or monitor mode.
a) The number of page faults will be These refer to the modes
more a) By which user program handle
b) The number of page faults will their data
be less b) By which the operating system
c) The number of page faults will executes user programs
remains the same c) In which the processor and the
d) Execution will be faster associated hardware operate.
d) Of memory access
Q.25 At a particular time of computation,
the value of a counting semaphore is Q.31 Disk scheduling involves deciding
7. Then 20p operations and ‘x’ v a) which disk should be accessed
operation were completed on this next
semaphore. If the final value of the b) the order in which disk access
semaphore is 5, x will be requests must be serviced.
a) 15 b) 22 c) the physical location where files
c) 18 d) 13 should be accessed in the disk
d) none of the above
Q.26 Pre-emptive scheduling, is the Q.32 A computer system has 6 tape
strategy of temporarily suspending a drives, with ‘n’ process is competing
running process for them. Each process may need 3
a) Before the CPU time slice expires drives. The maximum value of ‘n’ for
b) To allow starving processes to run which the system is guaranteed to
c) When it requests I/O be deadlock free is.
d) None of the above a) 2 b) 3
c) 4 d) 1
Q.27 Mutual exclusion problem occurs
a) Between two disjoint processes Q.33 Dirty bit is used to show the
that do not interact a) page with corrupted data
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
b) wrong page in the memory a) A re-entrant procedure can be
c) page that is modified after being called any number of times.
loaded into cache memory b) A re-entrant procedure can be
d) page that is less frequently called even before the procedure
accessed has not returned from its
previous call.
Q.34 Fence register is used for c) Re-entrant procedures cannot be
a) CPU protection called recursively.
b) Memory protection d) Re-entrant procedures can be
c) File protection called recursively.
d) all of the above
Q.41 In a paged memory, the page hit
Q.35 Which of the following is the service ratio is 0.35. The time required to
not supported by the operating access a page in secondary memory
system? is equal to 100 ns. The time required
a) Protection b) Accounting to access a page in primary memory
c) Compilation d)I/O operation in 10 ns. The average time required
to access a page is
Q.36 The first-fit, best-fit and the worst- a) 3.0 ns b) 68.0 ns
fit algorithm can be used for c) 68.5 ns d) 75.5 ns
a) contiguous allocation of memory
b) linked allocation of memory Q.42 A state is safe if the system can
c) indexed allocation of memory allocate resources to each process
d) all of the above. (up to its maximum) in some order
and still avoid deadlock.
Q.37 Which of the following are single- Which of the following are true?
user operating systems? a) Deadlock state is unsafe.
a) MS-DOS b) UNIX b) Unsafe state may lead to a
c) XENIX d) OS/2 deadlock situation.
c) Unsafe state must lead to a
Q.38 In Round Robin CPU scheduling, as deadlock situation.
the time quantum is increased, the d) Deadlock state is a subset of a
average turnaround time unsafe state.
a) Increases
b) Decreases Q.43 The size of the virtual memory
c) Remains constant depends on the size of
d) Varies irregularly a) data-bus b) main memory
c) address bus d) none of the above
Q.39 In a multiprogramming environment
a) the processor executes more Q.44 In a multi-user operating system, 20
requests are made to use a
than one process at a time
particular resource per hour, on an
b) the programs are developed by
average. The probability that no
more than one person
c) more than one process resides in request are made in 45 minutes is
a) e-15 b) e-5
the memory
c) 1 – e -5 d) 1 – e-10
d) a single user can execute many
programs at the same time.
Q.45 In which of the scheduling policies
does context switching never take
Q.40 Which of the following are true?
place during process execution?
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
a) Round-robin d) user programme can implement
b) Non Pre-emptive Shortest job first dynamic loading without any
c) Pre-emptive special support from the
d) First-cum-first-served operating system or the
hardware.
Q.46 In which of the following directory
systems, is it possible to have Q.50 Which of the following is true?
multiple complete paths for a file, a) The linkage editor is used to edit
starting from the root directory? programs which have to be later
a) Single level directory linked together
b) Two level directory b) The linkage editor links object
c) Tree structured directory modules during compilation or
d) Acyclic graph directory assembling
c) The linkage editor links object
Q.47 Suppose that a process is modules and resolves external
‘BLOCKED’ state waiting for some references between them before
I/O service. When the service is loading.
completed, it goes to the d) The linkage editor resolved
a) RUNNING state external references between the
b) READY state object modules during execution
c) SUSPENDED state time.
d) TERMINATED state
Q.51 Which of the following is true?
Q.48 In a system that does not support a) Overlays are used to increase the
swapping size of physical memory.
a) the compiler normally binds b) Overlays are used to increase the
symbolic address (variables) to logical address space
reloadable addresses. c) When overlays are used, the size
b) the compiler normally binds symbolic of process is not limited to the
address to physical addresses. size of physical memory.
c) the loader binds reloadable d) Overlays are used whenever the
addresses to physical addresses. physical address space is smaller
d) binding of symbolic addresses to than the logical address space.
physical addresses normally takes
place during execution. The next 5 questions are based on the
following information.
Q.49 To obtain better memory utilization, Consider a set of 5 processes whose arrival
dynamic loading is used. With time, CPU time needed and the priority are
dynamic loading, a routine is not given below:
loaded until it is called for. For
implementing dynamic loading,
a) special support from hardware
is essential.
b) special support from operating
system is essential.
c) Special support from both
hardware and operating system Note: Smaller the number, higher the
are essential. priority.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.52 If the CPU scheduling policy is FCFS,
the average waiting time will be Q.59 For implementing of multi
a) 12.8 ms b) 8 ms programming operating system
c) 16 ms d) None of the above a) Special support from processor
is essential
Q.53 If the CPU scheduling policy is SJF,
b) Special support from processor
the average waiting time (without is not essential
pre-emption) will be
c) Cache memory must be available
a) 12.8 ms b) 6.8 ms d) More than one processor must
c) 17 ms d) None of the above
be available.
Q.54 If the CPU scheduling policy is SJF Q.60 Consider a system having ‘m’
with pre-emption, the average resources of the same type. These
waiting time will be resources are shared by 3 processes
a) 8 ms b) 14 ms A, B, C, Which have peak time
c) 5.6 ms d) none of the above demands of 3, 4, and 6 respectively.
The minimum value of ‘m’ that
Q.55 If the CPU scheduling policy is ensures that deadlock will never
priority scheduling without pre- occur is
emption, the average waiting time a) 11 b) 12
will be c) 13 d) 14
a) 12.8 ms b) 11.8 ms
Q.61 A system has 3 processes sharing 4
c) 10.8 ms d) none of above
resources. If each process needs a
Q.56 If the CPU scheduling policy is maximum of 2 units, then deadlock
priority scheduling with pre- a) Can never occur
emption, the average waiting time b) may occur
will be b) Has to occur
a) 19 ms b) 7.6 ms d) none of the above
c) 8 ms d) None of above
Q.62 ‘m’ processes share ‘n’ resources of
Q.57 In partitioned memory allocation the same type. The maximum needs
scheme, the of each process don’t exceed ‘n’ and
a) best fit algorithm is always the sum of all their maximum needs
better than the first fit algorithm. is always less than m + n. In this set
b) first fit algorithm is always better up deadlock
than the best fit algorithm. a) can never occur
c) superiority of the first fit and b) may occur
best-fit algorithms depends on c) has to occur
the sequence of the memory d) None of the above
request.
d) None of above Q.63 A process refers to 5 pages, A, B, C, D
and E in the order – A; B; C; D; A; B;
Q.58 Cascading termination refers to E; A; B; C; D; E. If the page
termination of the all child replacement algorithm if FIFO, the
processes before the parents number of pages which transfer
terminates with an empty internal store of 3
a) Normally frame is
b) abnormally a) 8 b) 10
c) Normally or abnormally c) 9 d) 7
d) None of the above
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.64 Distributed system should 20. The seek time is 6 ms per
a) Meet prescribed time constraints cylinder. The total seek time, if the
b) Aim better resource sharing disk arm scheduling algorithm is
c) Aim better system utilization first-come-first-served is
d) Aim low system overhead a) 360 ms b) 850 ms
c) 900 ms d) None of the above
Q.65 The main function of shared
memory is to Q.71 In question 70, if the scheduling
a) Use primary memory efficientl algorithm is the closest cylinder
b) Do intra process communication next, then the total seek time will b
c) Aim better system utilization a) 360 ms b) 876 ms
d) Aim low system overhead c) 850 ms d) 900 ms
Q.66 Which of the following is the most
Q.72 Certain moving arm disk storage
suitable scheduling scheme in a with one head has following
real–time operating system?
specification Number of tracks /
a) round-robin recording surface = 200 Disk
b) first-come-first-served
rotation speed = 2400 rpm Track
c) Pre-emptive scheduling storage capacity = 62500 bits The
d) random scheduling
average latency time (assume that
Q.67 In Question number 63, if the the head can move from one track to
number of available page frames is another only by traversing the
increased to 4 then the number of entire track) is
page transfers a) 2.5 s b) 2.9 s
a) decreases c) 3.1 s d) 3.6 s
b) increases
c) remains the same Q.73 Memory protection is normally done
d) none of the above by the
a) Processor and the associated
Q.68 ‘Aging’ is hardware
a) Keeping track of cache contents. b) Operating system
b) Keeping track of what pages are c) Compiler
currently residing in the d) User program
memory. Q.74 Which of the following scheduling
c) Keeping track of how many algorithms gives minimum average
times a given page is referenced. waiting time?
d) Increasing the priority of jobs to a) FCFS b) SJF
ensure termination in a finite c) Round-robin d) Priority
time.
Q.75 In question number 72, the transfer
Q.69 If there are 32 segments, each of rate will be
size 1 Kbytes, then the logical a)2.5 Mbits/s b) 4.25 Mbits/s
address should have c)1.5 Mbits/s d)3.75 Mbits/s
a) 13 bits b) 14 bits
c) 15 bits d) 16 bits Q.76 In a paged segment scheme of
Q.70 Disk requests come to a disk driver memory management, the segment
for cylinders in the order 10, 22, 20, table itself must have a page table
2, 40, 6 and 38, at a time when the because
disk drive is reading from cylinder a) the segment table is often too
large to fit in one page
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
b) each segment is spread over a a) 15, 4 b) 6, 4
number of pages c) 7, 2 d) 4, 6
c) segment table point to page
tables and not to the physical Q.81 A computer installation has 1000 k
location of the segment of main memory. The jobs arrive
d) the processor’s description base and finish in the following sequence.
register point to a page table Job 1 requiring 200 K arrives
Job 2 requiring 350 K arrives
Q.77 Which of the following scheduling Job 3 requiring 300 K arrives
policy is well suited for a time- Job 1 finishes
shared? Operating system? Job 4 requiring 120 K arrives
a) FIFO Job 5 requiring 150 K arrives
b) Pre-emptive scheduling Job 6 requiring 80 K arrives
c) Round Robin Among best fit and first fit, which
d) both FIFO and Pre-emptive performs better for this sequence?
a) First fit
Q.78 Which of the following scheduling b) Best fit
policy is well suited for a time- c) Both perform the same
shared operating system? d) None of the above
a) Shortest job first
b) Round robin Q.82 A memory page containing a heavily
c) First-come-first-serve used variable that was initialized
d) Elevator very early and is in constant use is
removed. When the page
Q.79 The address sequence generated by replacement algorithm used is
tracing a particular executing in a a) LRU b) FIFO
pure demand paging system with c) LFU d) None of the above
100 records per page, with 1 free
main memory frame is recorded as Q.83 Consider the following heap. The
follows. What is the number of page sequence of request for blocks of
faults? sizes 300, 25, 125, 50 can be
0100,0200,0430,0499,0510,0530,05 satisfied if we use
6, 0120,0220,0240,0260,0320,0370. a) Either first fit or best fit policy
a) 13 b) 8 b) first fit but not best fit
c) 7 d) 10 c) Best fit but not first fit
Q.80 A computer system has 4 k word d) None of the above
cache organized in a block-set-
associative manner, with 4 blocks Q.84 Consider the resources allocation
per set, 64 words per block. The graph. This system is in a deadlock
number of bits in the SET and state. This remark is
WORDS fields of the main memory a) True
address format is b) false
c) Impossible to determine
d) unpredictable
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.86 A demand paging system, with page c) Time sharing 3) LIFO
table had held in registers, takes 5 d) Interrupt processing 4) FIFO
ms to service a page fault if an Is:
empty page is available, or if the a) A–3,B-4,C-2,D-1
page to be replaced in not dirty. It b) A–4,B-3,C-2,D-1
takes 15 ms if the replace page is c) A–2,B-4,C-1, D-3
dirty. Memory access time is 1μs. d) A–2,B-1,C-4,D-3
Assume we want an effective access
time of 2μs. And that the page to be Q.91 Thrashing
replaced is dirty 60% of the time. a) reduces page I/O
What is the approximate maximum b) decreases the degree of
acceptable page fault rate to meet multiprogramming
this access time requirement? c) implies excessive page I/O
a) 0.1 % b) 1.0 % d) improves the system performance
c) 2.5 % d) 0.01 %
Q.92 Dirty bit for a page in a page table
a) helps avoid unnecessary writes
Q.87 Consider a computer with 8 Mbytes
on a paging devise
if main memory and a 128 k cache.
The cache block size is 4 K. It uses a b) helps maintain LRU information
c) allows only read on a page
direct mapping scheme for cache
management. How many different d) None of the above
main memory can map onto a given Q.93 Each process Pi, i = 1, 2, 3 ...., 9 is
a given physical cache block? coded as follows
a) 2048 b) 256 Repeat
c) 64 d) None of the above P (mutex)
Q.88 Which of the following applications { critical section }
are well suited for batch processing? V (mutex)
a) Process control Forever
b) Video game control The code for P10 is identical except
c) Preparing pay bills of employees that it uses V (mutex) instead of P
d) Preparing mailing address (mutex). What is the largest number
of processes that can be inside the
Q.89 Locality of reference implies that the critical section at any of the
page reference being made by a movement?
process a) 1 b) 2
a) will always to be the page used c) 3 d) none of the above
in the previous page reference.
b) is likely to be one of the pages Q.94 When an interrupt occurs, an
used in the last few page operating system
reference. a) ignores the interrupt
c) will always be one of the pages b) always change the state of the
existing in memory interrupted process after
d) will always leads to page fault. processing the interrupt
c) always resumes execution of the
Q.90 The correct matching for the interrupted process after
following pairs processing the interrupt
a) Disk scheduling 1)Round d) may change the state of the
robin interrupted process to “blocked”
b) Batch processing 2) SCAN and schedule another process.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.95 On a system with n CPUs, what is the Q.101 Necessary conditions for deadlock
maximum number of processes that are
can be in the ready, run and blocked a) non-preemption and circular
states ? wait
a)
n
b)
n b) mutual exclusion and partial
2 3 allocation
c) n d) None. c) both a) and b)
d) none of the above.
Q.96 Given system with n processes, how
many possible ways can those Q.102 In a time-sharing operating system,
processes be scheduled ? when the time slot given to a
a) n b) n process is completed, the process
c)
n
d) None. .goes from the RUNNING state to the
2 a) BLOCKED state
b) READY state
Q.97 On a system with 224 bytes of c) SUSPENDED state
memory and fixed partitions, all of d) TERMINATED state.
size 65,536 bytes, what is the
minimum number of bits needed in Q.103 A sequential access file has fixed-
an entry in the process table to size 15-byte records. Assuming the
record the partition to which a first record is record 1, the first byte
process has been allocated ? of record 5 will be at what logical
a) 2 b) 4 location?
c) 6 d) 8 a) 41 b) 51
c) 61 d) None.
Q.98 On a system with 224 bytes of
memory and fixed partitions, all of Q.104 A direct access file has fixed-size 15
size 65, 536 bytes, how many bits byte records. Assuming the first
must the limit register have record is record 1, the first byte of
a) 4 b) 8 record 5 will be at what logical
c) 12 d) 16. location?
a) 41 b) 51
Q.99 On a system using fixed partitions c) 61 d) none.
with sizes 216, 224, and 232, how
many bits must the limit register Q.105 A direct or sequential access file has
have? fixed-size S-byte records. The first
a) 16 b) 24 byte of record N will start at what
c) 32 d) None. logical location ?
a)[(N+ 1 )*S]+1 b)[(N-1)*S]-1
Q.100 With a single resource, deadlock c) (N-1)* S+1] d) None.
occurs
a) if there are more than two Q.106 A program has just read the tenth
processes competing for that record in a sequential access file. It
resource next wants to read the sixth record.
b) if there are only two process How many records must the
competing for that resource program read to input the sixth ?
c) if there is a single process a) 4 b) 5
competing for that resource c) 6 d) None.
d) none of the above.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.107 On a system using a free hole array, Q.114 On a system using multilevel
and that has K physical blocks, what feedback queues, a totally CPU-
is the maximum length of a free hole bound process requires 40 seconds
array? The minimum length? to execute. If the first queue uses a
a) 0 b) 1 time quantum of 2 and at each level
c) 2 d) 3. the time quantum increases by 5
time-units, how many times will the
Q.108 At a particular time, the value of a job be interrupted ?
counting semaphore is 10. It will a) 2 b) 3
become 7 after c) 4 d) None
a) 3 V operations
b) 3 P operations Q.115 On a system using non-preemptive
c) 5V operations and 2P operations scheduling, processes with expected
d) 13P operations and 10V run times of 5, 18, 9 and 12 are in
operations. the ready queue. In what order
should they be run to minimize
Data of Q.109- Q.113 are given : wait time?
One a system using round-robin a) 5, 12, 9, 18 b) 5, 9, 12, 18
scheduling, let s represent the time needed c) 12, 18, 9, 5 d) None.
to perform a process switch, q represent
the round-robin time quantum, and r Q.116 On a computer system with a single
represent the average time a process runs 32-bit 100 MHz bus (10ns cycle),
before blocking on I/0. CPU efficiency is the disk controller uses DMA to
Q.109 q = ∞ transfer data to/from memory at a
a) r b)
1 rate of 40Mb per second. Assume
rs the computer fetches and executes
c)
r
d) None one 32-bit instruction every cycle
rs when no cycles are stolen. By what
percentage will the disk controller
Q.110 q > r slow down instruction execution ?
a) r b)
1 a) 5% b) 10%
rs c) 15% d) 20%.
r
c) d) None.
rs
Q.117 A computer system that uses
memory-mapped I/O has a 16-bit
Q.111 s < q < r address space Addresses with ones
1
a) q b) in the two most significant bits refer
qs
to devices. What is the maximum
q amount of memory that can be
c) d) None.
qs referenced in such a system?
a) 27 b) 29
Q.112 s = q = r c)211 d) 214
1 1
a) b)
3 2 Q.118 A disk file contains 32-byte fixed-
1
c) d) None size records. Physical 1/0 is in
5
terms of 512 byte blocks that are
stored in an operating system
Q.113 q nearly 0 buffer. If a process sequentially
a) 0 b) 1 reads though a file's records, what
c) 1/2 d) None
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
percentage of the read requests will pages of logical address space, and a
result in I/O operations? page size of 210 bytes, No. of entries
a) 5.25% b) 6.25% are in the page table (how long is
c) 7.25% d) None. the page table)?
a) 156 entries b) 186 entries
Data of Questions Q.119- Q.120 are c) 226 entries d) 256 entries.
given:
On a system using a disk cache, the mean Q.125 On a simple paging system with 2 24
access time is dependent on the mean bytes of physical memory, 256
cache access time, the mean disk access pages of logical address space, and a
time, and the hit rate. For the following, page size of 210 bytes, No. of bits are
what is the mean access time? needed to store an entry in the page
table (how wide is the page table)?
Q.119 Cache:1ms; disk;100ms; hit rate: a) 4 b) 7
25% c) 9 d) 14.
a) 50 b) 70
c) 75.25 d) None Q.126 At a particular time of computation,
the value of a counting semaphore is
Q.120 Cache:1ms;disk:100ms; 7. Then 20 P operations and 'x'. V
hit rate:50% operations were completed on this
a) 30 b) 40 semaphore. If the final value of the
c) 50.50 d) None. semaphore is 5, x will be
a) 15 b) 22
Q.121 On a simple paging system with 2 24 c) 18 d) 13.
bytes of physical memory, 256
pages of logical address space, and a Q.127 A computer system has 6 tape
page size of 210 bytes, No. of bits are drives, with 'n' processes competing
in a logical address ? for them. Each process may need 3
a) 10 b) 12 tape drives. The maximum, value of
c) 16 d) 18. 'n' for which the system is
guaranteed to be deadlock free is
Q.122 On a simple paging system with 2 24 a) 2 b) 3
bytes of physical memory, 256 c) 4 d) 1.
pages of logical address space, and a
page size of 210 bytes, No. of bytes Q.128 In a paged memory, the page hit
are in a page frame? ratio is 0,35. The time required to
a) 26 bytes b) 28 bytes access a page in secondary memory
c) 210 bytes d) None. is equal to 100 ns. The time required
to access a page in primary memory
Q.123 On a simple paging system with 24 24 is 10 ns. The average time required
bytes of physical memory, 256 to access a page is
pages of logical address space, and a a) 3.0 ns b) 68.0 ns
page size of 210 bytes, No. of bits in c) 68.5 ns d) 78.5 ns.
the physical address specify the
page frame. Q.129 In a multiuser operating system, 20
a) 10 b) 12 requests are made to use a
c) 14 d) None. particular resource per hour, on an
average. The probability that no
Q.124 On a simple paging system with 2 24 requests are made in 45 minutes is
bytes of physical memory, 256
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
a) e-15 b) e-5 a) 1, 6, 7, 3 b) 2, 6, 7, 3
c) 1-e-5 d) 1-e-10 c) 2, 6, 3, 7 d) None.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.147 In shortest remaining time Q.154 LOOK
a) 1.5 b) 2 a) 809 b) 909
c) 2.5 d) None. c) 1009 d) None.
Q.150 On a system using a disk cache, the Data of Questions. Q.157- Q.160 are
mean access time is 41.2 ms, the given :
mean cache access time is 2 ms, the A page size of 2000 bytes, and the following
mean disk access time is 100 ms, page table in given
and the system has 8 Mb of cache In/out Frame
memory. For each doubling of the in 20
amount of memory, the miss rate is out 22
halved. How much memory must in 200
be added to reduce the mean access in 150
time to 20 ms? out 30
a) 10.8 b) 11.8 out 50
c) 12.8 d) None. in 120
in 101
Data of Questions. Q.151- Q.155 are Which of the following virtual addresses
given : generate a page fault ?
On a disk with 1000 cylinders, numbers 0
to 999, compute the number of tracks the Q.157 10451
disk arm must move to satisfy all the a) 5421 b) Fault
requests in the disk queue. Assume the last c) 3421 d) None.
request serviced was at track 345 and the
head is moving toward track 0. The queue Q.158 5421
in FIFO order contains requests for the a) 301, 321 b) 401, 421
following tracks : 123, 874, 692, 475, 105, c) 501, 521 d) None.
376. Perform the computation for the
following scheduling algorithms : Q.159 14123
a) 202, 123 b) Fault
Q.151 FIFO c) 102, 113 d) None.
a) 1013 b) 1713
c) 2013 d) None. Q.160 9156
a) 101, 104 c) 103, 105
Q.152 SSTF b) Fault d) None.
a) 1198 b) 1298
c) 1398 d) None. Data of Questions. Q.161 Q.165 are given :
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Process Arrival time CPU time Priority Sectors per track 63
priority (in ms) needed(in ms) What is the maximum size disk
P1 0 10 5
these systems could use?
P2 0 5 2
P3 2 3 1
a) 328 MB b) 428 B
P4 5 20 4 c) 528 B d) None
P5 10 2 3
Answer the questions based on the above Data of Questions. Q.167- Q.168 are
information (smaller the number, higher given :
the priority) : A disk has 8 sectors per track and spins at
600 rpm. It takes the controller 10 ms from
Q.161 If the CPU scheduling policy is FCFS, the end of one 1/0 operation before it can
the average waiting time will be issue a subsequent one. How long does it
a) 12.8 ms take to read all 8 sectors using the
b) 8 ms following interleaving systems ?
c) 16 ms
d) None of the above.
Q.162 If the CPU scheduling policy is SJF, Q.167 No interleaving
the average waiting time (without a) 400 ms b) 500 ms
pre-emption) will be c) 600 ms d) 800 ms.
a) 12.8 ms
b) 6.8 ms Q.168 Single interleaving
c) 17 ms a) 50 ms b) 100 ms
d) None of the above. c) 150 ms d) 200 ms.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
each, and a page size of 512 bytes, Q.178 Given a system using unspanned
how many bits in the logical address blocking and 100 byte blocks. A file
specify the page number? contains records of 20, 50, 35, 70,
a) 2 b) 4 40, 20. What percentage of space
c) 6 d) None. will be wasted in the blocks
allocated for the file?
Q.173 On a simple paging system with a a) 31.25% b) 41.25%
page table containing 64 entries of c) 51.25% d) None.
11 bits (including valid/invalid bit)
each, and a page size of 512 bytes, Q.179 Consider a system having 'm'
how many bits in the logical address resources of the same type. These
specify the offset within the page ? resources are shared by 3 processes
a) 3 b) 5 A, B, C, which have peak time
c) 7 d) 9 demands of 3, 4, 6 respectively. The
minimum value of 'm' that ensures
Q.174 On a simple paging system with a that deadlock will never occur is
page table containing 64 entries of a) 11 b) 12
11 bits (including valid/invalid bit) c) 13 d) 14.
each, and a page size of 512 bytes,
how many bits are in a logical Q.180 A system has 3 processes sharing 4
address? resources. If each process needs a
a) 9 b) 11 maximum of 2 units then
c) 13 d) 15. a) deadlock can never occur
b) deadlock may occur
Q.175 On a simple paging system with a c) deadlock has to occur
page table containing 64 entries of d) none of the above.
11 bits (including valid/invalid bit)
each, and a page size of 512 bytes, Q.181 'm' processes share 'n' resources of
what is the size of the logical the same type. The maximum need
address space ? of each process doesn't exceed 'n'
a) 27 b) 29 and the sum all their maximum
c) 211 d) 215 needs is always less than m + n. In
this set-up,
Q.176 On a capability-based system, each a) deadlock can never occur
file is associated with a unique 16 b) deadlock may occur
bit number. For each file, each user c) deadlock has to occur
may have the read or write d) none of the above.
capability. How many bytes are
needed to store each user's access Q.182 A process refers to 5 pages, A, B, C, D
data? and E in the following order
a) 65536 b) 16384 A;B;C;D;A; B;E;A;B;C;D;E. If the page
c) 26384 d) None. replacement algorithm is FIFO, the
number of page transfer with an
Q.177 On a system using fixed blocking empty internal store of 3 frames is
with 20-byte records and 50 byte a) 8 b) 10
blocks, how much space will be c) 9 d) 7
wasted in each block?
a) 5 bytes b) 10 bytes Q.183 Consider a system in which a
c) 15 bytes d) None. directory entry can store upto 16
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
disk block addresses. For files no Q.188 If the number of available page
larger than blocks, the 16 addresses frames is increased to 4 then
serve as the file's index table. For a) the number of page transfers
files larger than 16 blocks, the decreases
addresses point to indirect blocks b) the number of page transfers
which in turn point to 256 file increases
blocks each. A block is 1024 bytes. c) the number of page transfers
How big can a file be? remains the same
a) 27 b) 2" d) none of the above.
c) 222 d) None.
Q.189 If there are 32 segments, each of
Data of Questions Q.184-Q.185 are given: size 1 k byte, then the logical
How many bits would be needed to store address should have
the free list under the following conditions a) 13 bits b) 14 bits
if a bit map were used to implement the c) 15 bits d) 16 bits.
free list ?
Q.190 Disk requests come to a disk driver
Q.184 For 16 bits per disk address ; for cylinders 10, 22, 20, 2, 40, 6 and
500,000 blocks total ; 200,000 free 38, in that order at a time when the
blocks disk drive is reading from
a) 200,000 b) 300,000 cylinder 20. The seek time is 6 ms
c) 400,000 d) 500,000 per cylinder. The total seek time,
I the disk arm scheduling algorithm
Q.185 For 16 bits per disk address; is first-come- first-served is
500,000 blocks total ; 0 free blocks a) 360 ms b) 850 ms
a) 200,000 b) 300,000 c) 900 ms d) None of the above.
c) 500,000 d) None.
Q.191 A certain moving arm disk storage
Q.186 On a system with D bits per disk with one head has following
address, B blocks total, and F free specifications :
blocks, under what conditions will Number of tracks/recording surface
the free list array use less space = 200
than the bit map? Disk rotation speed = 2400 rpm
a)D×F=B b)D×F>B Track storage capacity = 62500 bits
c)D×F<B d) None.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
ANSWER KEY:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
(c ) (c ) (c ) (c ) (c ) (c ) (b) (a) (a) (d) (d) (b) (a) (b)
15 16 17 18 19 20 21 22 23 24 25 26 27 28
(b) (b) (c ) (d) (c ) (b) (b) (c ) (b) (b) (c ) (a) (b) (c )
29 30 31 32 33 34 35 36 37 38 39 40 41 42
(d) (c ) (b) (a) (c ) (b) (c ) (a) (a) (d) (c ) (b) (c ) (a)
43 44 45 46 47 48 49 50 51 52 53 54 55 56
(d ) (d) (b) (d) (b) (a) (d) (c ) (c ) (a) (b) (c ) (c ) (b)
57 58 59 60 61 62 63 64 65 66 67 68 69 70
(c ) (c ) (b) (a) (a) (a) (c ) (b) (c ) (c ) (b) (d) (c ) (d)
71 72 73 74 75 76 77 78 79 80 81 82 83 84
(a) (a) (a) (b) (a) (b) (c ) (b) (c ) (d) (a) (b) (b) (b)
85 86 87 88 89 90 91 92 93 94 95 96 97 98
(c ) (d) (c ) (c ) (b) (c ) (c ) (a) (c ) (d) (c) (b) (d) (d)
99 100 101 102 103 104 105 106 107 108 109 110 111 112
(c) (d) (c) (b) (c) (c) (c) (c) (a) (b) (c) (c) (c) (b)
113 114 115 116 117 118 119 120 121 122 123 124 125 126
(a) (c) (b) (b) (d) (b) (c) (c) (d) (c) (c) (d) (d) (c)
127 128 129 130 131 132 133 134 135 136 137 138 139 140
(a) (c) (a) (c) (b) (b) (d) (d) (b) (b) (b) (b) (b) (c)
141 142 143 144 145 146 147 148 149 150 151 152 153 154
(b) (b) (c) (b) (d) (c) (c) (d) (c) (b) (c) (b) (c) (c)
155 156 157 158 159 160 161 162 163 164 165 166 167 168
(c) (c) (b) (b) (a) (b) (a) (b) (c) (c) (b) (c) (d) (d)
169 170 171 172 173 174 175 176 177 178 179 180 181 182
(c) (d) (d) (c) (d) (d) (d) (b) (b) (b) (a) (a) (a) (c)
183 184 185 186 187 188 189 190 191
(c) (d) (c) (c) (b) (b) (c) (d) (a)
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
EXPLANATIONS
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.62 (a) To cover 2400×62500 bits, 60 s
Using Banker's algorithm, one can are needed. Average latency time
show that one process has to is the needed to traverse 100
enquire all its needed resources. tracks i.e., 100 ×62500 bits, which
This process after completing its are 2.5 S.
task, will release all its resource,
thereby avoiding any possible Q.78 (b)
deadlocks. As this scheduling policy has a
better average response time for
Q.63 (c) the interactive users.
The first 3 references A, B, C fills
the internal storage with A, B, C in Q.79 (c)
3 page transfer. Now the next When it tries to access 0100, it
reference D results in a page fault. results in a page fault as the
So, page A is downloaded and D memory is empty tight now. So, it
takes its place after a page loads the second page (which has
transfer. So, the internal store has the address 100-199), Typing to
D, B and C. The next reference is A- access 200 will result in a page
results in a page fault. So, a page fault, as it not in memory right
transfer takes place and swaps B now. So the third page with the
and A. Continuing this way, we find address from 200 to 299 will
totally 9 page transfers are replace the second page in
necessary. memory. Trying to access 430 will
result in another page fault.
Q.67 (b) Proceeding this way, we find trying
Refer Qn 63, Applying the same to access the address 0510, 0120,
logic, we find the required number 0220 and 0320 will all result in
of page transfer is 10. So, page faults. So, all together 7 page
increasing the number of pages faults.
need not necessarily reduce the
number of page faults. It is the Q.80 (d)
actual sequence of references that There are 64 words in a block. So
decides. the 4K cache has (4×1024)/64= 64
blocks. Since 1 set has 4 blocks,
Q.69 (c) there are 16 sets. 16 sets need 4
To specify a particular segment, 5 bits for representation. In a set
bits are required (since 25=32). there are 4 blocks, which needs 2
Having selected page, to select a bits. Each block has 64 words. So,
particular byte one needs 10 bits the word field has 6 bits.
(since 210=1 K byte).So, totally 5 +
10 = 15 bits are needed. Q.81 (a)
The memory configuration after
Q.70 (d) the arrival of the jobs 1, 2, 3 and
The disk drive has to traverse the termination of job 1 can be
totally 146 cylinders (verify). So, depicted as:
Seek time is 6 × 146 = 876 ms
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
algorithm will allocate the FREE- …, 9 (expecting the one that is
150 slot for job 4. The memory already inside the critical section)
configuration for the first fit and can get into the critical section
best fit will be after decrementing the mutex to 0.
None of the remaining processes
can get into the critical section. If
And the mutex is initialized to 0, only 2
processes can get into the critical
section. So the largest number of
respectively. When job 5 arrives, it processes is 3.
will be allotted the FREE-150 slot
by the first fit algorithm and the Q.95 (c)
FREE-200 slot by the first fit There is no limit to the number or
algorithm. The memory allocation processes that can be in the ready
table for the first fit and best fit and blocked states. At most, n
will be processes may be in the run state,
since a process in the run state
and must be allocated to a CPU, and
there are only n CPUs.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Since the system has only one limit Since processes will still run until
register, it must be large enough to they block, the answer is the same
accommodate addresses in any as for part (a).
partition. The largest possible
partition is 232 Therefore. The limit Q.111 (c)
register must have 32 bits. The number of switches required
will be r/q, making the time
Q.103 (c) wasted on switches sr/q. CPU
Record 5 is preceded by 4 records, r r
efficiency is =
each of 15 bytes. The fifth record r sr / q q s
will start at byte (4*15)+1=61.
Q.112 (b)
Q.104 (c)
Same answer as above except with
The logical layout of the records is
1
the same for both access methods. q=s, the equation evaluates to .
2
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.120 (c) remaining 2 P operations result
100×0.50 + 1×0.50 = 50.50. in the semaphore value 5.
Q.121 (d)
The logical address space contains Q.127 (a)
256= 28 pages of 210 bytes, making 2 process can never lead to
the total logical address space deadlock as the peak time demand
210×218=218 bytes. An 18 bit of 6(3+3) tape drives can be
address is required to cover a 218 satisfied. But 3 processes can lead
byte address space. to a deadlock if each hold 2 drives
and then demand one more.
Q.122 (c)
The page frame size is the same as Q.128 (c)
0.35×10+(1-0.35) ×100=68.5ns.
the page size. Therefore, the page
frame size is 210 bytes.
Q.129 (a)
The arrival pattern is a Poisson
Q.123 (c)
A 24 bit address is required to distribution.
P (k requests)= e-μT(μT)k/k
cover the 224 byte physical
address space. Since pages, and Here k= 0, μ= 20, T = 3/4.
therefore page frames, are 210 So required probability is e-15.
bytes, the last 10 bits in the
physical address specify the page Q.130 (c)
Turnaround time is computed by
offset. The remaining 14 bits
specify the page frame number. subtracting the time the process
entered the system from the time
it terminated.
Q.124 (d)
The page table must contain an 3 0 9 1 13 4 15 6 = 7.25
entry for each page. Since there 4
are 256 pages in the logical
address space, the page table must Q.131 (b)
be 256 entries long. 3 0 9 1 15 4 11 6 =6.75
4
Q.125 (d)
Each entry contains 1 bit to Q.132 (b)
indicate if the page is valid and 14 3 0 15 1 8 4 10 6 = 6.25
bits to specify the page frame 4
number.
Q.133 (d)
Q.126 (c) 5 0 13 1 15 4 11 6 = 8.25
Each P operation will decrease the 4
semaphore value by 1 and V
operation increase by 1. If x is 18, Q.134 (d)
then 7P operations will make the 4 0 15 1 14 4 12 6 = 8.50
semaphore value 0. If this is 4
followed by 7V operations the
value comes back to 7. So, after Q.135 (b)
10P and 18V operations, the value
of the semaphore will be 7. The
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Wait time can be computed by Q.149 (c)
subtracting a process's execution 4.00
time from its turn round time.
A:(3-3)=0, B:(8-6)=2, Q.150 (b)
C:(9-4)=5, D:(9-2)=7. The hit ratio can be computed
from the equation,
Q.136 (b) 2×(1-m)+ 100 m=41.2
A:(3-3 )= 0, B:(8-6)=2, 2-2 m+ 100 m=41.2
C:(11-4)=7, D:(5-2 )=3 39.2 = 98 m 0.40 = m
Doubling memory to 16 Mb would
Q.137 (b) lower the miss rate to 0.20.
A :(3-3)= 0, B:(14-6)= 8, 2×0.80+100×0.20=21.6
C:(4 -4)= 0, D:(4-2)=2. An additional doubling to 32 Mb
would be needed to lower the
Q.138 (b) mean access time below 20 ms.
A:(5-3)=2, B:(12-6)=6, 2×0.90+100×0.10= 11.8.
C:(11-4 )= 7, D:(5-2)=3.
Q.151 (c)
Q.139 (b) The tracks travelled to will be 345,
A:(4-3)= 1, B:(14-6)=8, 123, 874, 692, 475, 105 and 376,
C:(10-4)= 6, D:(6-2)=4. making the total distance 222+ 751
+182 +217 +370 +271 =2013
Q.140 (c)
A : 4, B : 9, C : 10, D : 12 Q.152 (b)
The tracks travelled to will be 345,
Q.141 (b) 376, 475, 692, 874, 123and 105,
A : 4, B:13, C : 3, D:5 making the total distance 529+769
= 1298.
Q.142 (b)
A : 4, B : 13, C : 3, D : 5 Q.153 (c)
The tracks travelled to will be 345,
Q.143 (c) 123, 105, 0, 376, 475, 692 & 874,
A : 4, B:13, C:5, D:7 making the total distance 345+874
= 1219.
Q.144 (b)
A:5, B:13, C:6, D:7 Q.154 (c)
The tracks travelled to will be
Q.145 (d) 345,123, 105, 376, 475, 692 and
5.00 874, making the total distance 240
+ 769 = 1009.
Q.146 (c)
2.50 Q.155 (c)
The tracks travelled to will be 345,
Q.147 (c) 123, 105, 0, 999, 874, 692, 475 &
2.50 376, making the total distance
345+999+623=1967
Q.148 (d)
3.50 Q.156 (c)
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
The tracks travelled to will be 345, It is 30 + 3 + 0 + 5 + 0 divided by 5,
123, 105, 874, 692, 475 & 376, i.e., 7.6 ms.
making the total distance 240+
769+ 498 = 1507. Q.166 (c)
1024 x 16 x 63 x 512 =
Q.157 (b) 528,482,304 = 528 Mb.
Virtual address 10451 is offset 451
in page 5. Page 5 is "out" resulting Q.167 (d)
in a fault. The disk makes 10 revolutions per
second or one revolution in 100
Q.158 (b) ms. In 10 ms, less than one sector
Virtual address 5421 is offset 1421 will have passed under the
in page 2. Page 2 is "in" at frame read/write head. The next sector
200 which is address 400,000. cannot be read until the disk makes
Adding the offset to the frame's almost a complete revolution. It will
starting address yields physical require 8 revolutions to read all 8
address 401, 421. sectors. At 100 ms per revolution,
it will take 800 ms.
Q.159 (a)
Virtual address 14123 is offset 123 Q.168 (d)
The next sector will spin under the
in page 7. Page 7 is "in" at frame
101 which is address 202,000. read/write head almost as soon as
Adding the offset to the frame's the next I/O operation is issued.
Two revolutions will be needed
starting address yields physical
address 202, 123. to read all 8 sectors, making the
total read time 200 ms.
Q.160 (b) Q.169 (c)
Virtual address 9156 is offset 1156 A total of 2.75 revolutions will be
in page 4. Page 4 is "out" resulting needed to read all 8 sectors, for a
in a fault. total time of 275 ms.
Q.161 (a) Q.170 (d)
It is 0+10+(15-2)+(18-5)+(38-10) Each track can be read in one
divided by 5, i.e., 12.8 ms. revolution, or 11.11ms. To read all
19456×16 tracks requires
Q.162 (b) approximately 3459 seconds. Seek
It is 8+0+3+15+8 divided by 5, i.e. time is (19456-1)×2=39s. Total
6.8 ms. time is 3498s= 58 min.
Q.163 (c) Q.171 (d)
It is 10 + 3 + 0 + 15 + 0 divided by Seek time will be 10 ms. Latency
5, i.e., 5.6 ms. time will be 5.55 ms. Transfer time
will be 0.18 ms. Total time is 15.73
Q.164 (c) ms.
It is 30 + 0 + 3 + 3 + 18 divided by
5, i.e., 10.8 ms. Q.172 (c)
Since there are 64= 26 pages, 6 bits
Q.165 (b) of the logical address are required
to specify the page number.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.173 (d) Q.180 (a)
Since a page is 512 = e bytes long, At least one process will be holding
9 bits are required to specify the 2 resources in case of a
offset within the page. - simultaneous demand from all the
processes. That process will
release the 2 resources, thereby
Q.174 (d) avoiding any possible deadlock.
The 6 most significant bits of the
logical address would specify the Q.181 (a)
page number, the 9 least Using Banker's algorithm, one can
significant bits would specify show that one process has to
the page offset, making the total acquire all its needed resources.
number of bits 15. This process, after completing its
task, will release all its resources,
Q.175 (d) thereby avoiding any possible
In the previous problem, the deadlock.
logical address was determined to
have 15 bits. A 15 bit address Q.182 (c)
creates an address space of 32,768 The first 3 references A, B, C fills
=215. the internal storage with A, B, C in
3 page transfers. Now the next
Q.176 (b) reference D results in a page fault.
Two bits are needed for each of So, page A is downloaded and D
65,536 (216) files. Thus, 131,072 takes its place, after a page
bits or 16,384 bytes would be transfer. So, the internal store has
needed. D, B and C. The next reference is A
results in a page fault. So, a page
Q.178 (b) transfer takes place and swaps B
The first block can contain the first and A. Continuing this way, we find
two records, leaving 30 bytes totally 9 page transfers are
wasted. The second block can only necessary.
contain the third record, wasting
65 bytes. The third block can only Q.183 (c)
contain the fourth record, wasting The largest possible file will have
30 bytes. The last two records will 16=24 indirect blocks. Since each
be allocated to the fourth block, indirect block can point to 256=28
which will contain 40 wasted blocks, the largest file has 256=28+4
bytes. Thus, of the 400 bytes in the blocks. Given a block size of 1024=
four blocks, 30+ 65 + 30 + 40 = 165 210, the maximum file size is
bytes, or 41.25% is 24+8+10= 222
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission
Q.186 (c)
D × F < B.
Q.187 (b)
32×F < B
B
F<
32
Less than one thirty-second of the
blocks can be free.
Q.188 (b)
Applying the same logic, we find
the required number of page
transfer is 10. So, increasing the
number of pages need not
necessarily reduce the number of
page faults. It is the actual
sequences of references that
decides.
Q.189 (c)
To specify a particular segment, 5
bits are required (since25=32).
Having selected a page, to select a
particular byte one needs 10 bits
(since 210= 1 k byte). So totally
5+10=15bits are needed.
Q.191 (a)
To cover 2400×62500 bits, 60 s
are needed. Average latency time
is the time needed to traverse 100
tracks i.e., 100×62500 bits, which
is 2.5 s.
© Copyright Reserved by Gateflix.in No part of this material should be copied or reproduced without permission