• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE CS 2012

Question 21

Consider the 3 processes, P1, P2 and P3 shown in the table.
Process           Arrival time         Time Units Required
   P1                0                         5
   P2                1                         7
   P3                3                         4
The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are
  • FCFS: P1, P2, P3
     RR2: P1, P2, P3
    
  •  FCFS: P1, P3, P2
     RR2: P1, P3, P2
    
  • FCFS: P1, P2, P3
     RR2: P1, P3, P2
    
  • FCFS: P1, P3, P2 
    RR2: P1, P2, P3
    

Question 22

Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.
  AcquireLock(L){
         while (Fetch_And_Add(L,1))
               L = 1;
   }
  ReleaseLock(L){
         L = 0;
   }
This implementation
  • fails as L can overflow
  • fails as L can take on a non-zero value when the lock is actually available
  • works correctly but may starve some processes
  • works correctly without starvation

Question 23

Suppose a fair six-sided die is rolled once. If the value on the die is 1, 2, or 3, the die is rolled a second time. What is the probability that the sum total of values that turn up is at least 6?
  • 10/21
  • 5/12
  • 2/3
  • 1/6

Question 24

An Internet Service Provider (ISP) has the following chunk of CIDR-based IP addresses available with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses to Organization A, and a quarter to Organization B, while retaining the remaining with itself. Which of the following is a valid allocation of addresses to A and B?

  • 245.248.136.0/21 and 245.248.128.0/22

  • 245.248.128.0/21 and 245.248.128.0/22

  • 245.248.132.0/22 and 245.248.132.0/21

  • 245.248.136.0/24 and 245.248.132.0/21

Question 25

Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
  • Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
  • Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
  • Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
  • Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

Question 26

Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
Program main;
  Var ...
  
    Procedure A1;
     Var ...
     Call A2;
    End A1
    
    Procedure A2;
      Var ...
  
      Procedure A21;
        Var ...
        Call A1;
        End A21
        
    Call A21;
  End A21
  
    Call A1;
  End main.

Consider the calling chain : Main->A1->A2->A21->A1 The correct set of activation records along with their access links is given by : gatecs2012activationrecord gatecs2012activationrecord
  • A
  • B
  • C
  • D

Question 27

A computer has a 256 KByte, 4-way set associative, write back data cache with block size of 32 Bytes. The processor sends 32 bit addresses to the cache controller. Each cache tag directory entry contains, in addition to address tag, 2 valid bits, 1 modified bit and 1 replacement bit. The number of bits in the tag field of an address is
  • 11
  • 14
  • 16
  • 27

Question 28

How many onto (or surjective) functions are there from an n-element (n >= 2) set to a 2-element set?
 

  • 2(2n - 2)
     

  • 2n - 2
     

  • 2n - 1
     

  • 2n
     

Question 29

Let G be a complete undirected graph on 6 vertices. If vertices of G are labeled, then the number of distinct cycles of length 4 in G is equal to

  • 360
     

  • 45
     

  • 30
     

  • 15
     

Question 30

A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is
  • O(n log n)
  • O(n2 log n)
  • O(n2 + log n)
  • O(n2)

There are 60 questions to complete.

Last Updated :
Take a part in the ongoing discussion