Subjects Subjects About Login

OS : 2010 GATE Questions

Questions : 6


QID : 258GATE-2010, 1M

Which of the following statements are true?

I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time

Options:
A) I only
B) I and III only
C) II and III only
D) I, II and III
Ans : Option D
Solution :
I. SRTF May cause starvation as shorter processes may keep coming and a long processes never gets CPU.
II. Preemption may cause starvation. If priority based scheduling with preemption is used, then a low priority process may never get CPU.
III. Round Robin Scheduling improves response time as all processes get CPU after a specified time.
QID : 57GATE-2010, 1M

Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.

Which one of the following statements describes the properties achieved?

Options:
A) Mutual exclusion but not progress
B) Progress but not mutual exclusion
C) Neither mutual exclusion nor progress
D) Both mutual exclusion and progress
Ans : Option A
Solution :
This is similar to strict alternation solution for synchronizing 2 processes. Whatever be the initial values of S1 and S2, only one process will break its while loop. So ME is guaranteed.

But progress is not guaranteed, because with initial values only one of the process will be able to enter in CS even if other process is not started.
e.g. if S1=0 and S2=0, the at start of system, P1 will not be able to enter in CS even if assume that P2 is not started its execution.
QID : 264GATE-2010, 2M

The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:

void enter_CS(X)
{
      while(test-and-set(X));
}

void leave_CS(X)
{
    X=0;
}

In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider the following statements:

I. The above solution to CS problem is deadlock-free
II. The solution is starvation free.
III. The processes enter CS in FIFO order.
IV More than one process can enter CS at the same time.

Which of the above statements is TRUE?

Options:
A) I only
B) I and II
C) II and III
D) IV only
Ans : Option A
Solution :
TSL provides mutual exclusion so more than one process can't enter CS.

There is no queue nor it follows FIFO, so starvation is possible.
QID : 259GATE-2010, 2M

The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0.

How many times will process P0 print '0' ?

Options:
A) At least twice
B) Exactly twice
C) Exactly thrice
D) Exactly once
Ans : Option A
Solution :

QID : 68GATE-2010, 2M

A system has n resources R0,…,Rn-1, and k processes P0,…..Pk-1. The implementation of the resource request logic of each process Pi. is as follows:

if (i % 2 == 0) {

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

}
else {

  if (i < n) request Rn-i ;
  if (i+2 < n) request Rn-i-2 ;

}

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

Options:
A) n = 40, k = 26
B) n = 21, k = 12
C) n = 20, k = 10
D) n = 41, k = 19
Ans : Option B
Solution :
Option A:

Even processes requests even resources AND odd processes requests odd resources.
i.e.
P0 requests R0 and R2
P2 requests R2 and R4 and so on...

P1 requests R39 and R37
P3 requests R37 and R35 and so on...

So there wont be any scenario of deadlock.

Option C: Similar to option A

Option D: All process request even resources:
i.e.
P0 requests R0 and R2
P2 requests R2 and R4 and so on...
...(P18 is last even process)
P18 requests R18 and R20

while,

P1 requests R40 and R38
P3 requests R38 and R36 and so on...
...(P19 is last odd process)
P19 requests R22 and R20

But there are no 2 processes requesting same two resources
.
QID : 257GATE-2010, 1M

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

Options:
A) 196
B) 192
C) 197
D) 195
Ans : Option A
Solution :
For first 100 pages (lets number from 1 to 100), page fault will occur.
Then in reverse order of access, for 4 pages (100, 99, 98 and 97), there will be no page fault because last 4 pages will already be in frames.

and for 96 to 1, page faults will occur.

Total Page faults: 196
 

Have a Question?


Submit Here

Previous GATE Papers


Year Key Organized by
2019 Key IIT Madras
2018 Key IIT Guwahati
2017(Set1) Key IIT Roorkee
2017(Set2) Key IIT Roorkee
2016(Set1) Key IISc
2016(Set2) Key IISc
Show All