GATE CS 2008

Last Updated :
Discuss
Comments

Question 1

Which combination of the integer variables x, y and z makes the variable a get the value 4 in the following expression?

C
a = ( x > y ) ? (( x > z ) ? x : z) : (( y > z ) ? y : z )
  • x = 3, y = 4, z = 2

  • x = 6, y = 5, z = 3

  • x = 6, y = 3, z = 5

  • x = 5, y = 4, z = 5

Question 2

The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:

P(s) : s =  s - 1;
if (s < 0) then wait;
V(s) : s = s + 1;
if (s <= 0) then wakeup a process waiting on s;

Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:

P(s) : Pb(Xb);
s = s - 1;
if (s < 0) {
Vb(Xb) ;
Pb(Yb) ;
}
else Vb(Xb);

V(s) : Pb(Xb) ;
s = s + 1;
if (s <= 0) Vb(Yb) ;
Vb(Xb) ;

The initial values of Xb and Yb are respectively

  • 0 and 0

  • 0 and 1

  • 1 and 0

  • 1 and 1

Question 3

A process executes the following code

for (i = 0; i < n; i++) fork();

The total number of child processes created is

  • n

  • 2n - 1

  • 2n

  • 2(n+1) - 1

Question 4

Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then

  • T(n) <= 2T(n/5) + n

  • T(n) <= T(n/5) + T(4n/5) + n

  • T(n) <= 2T(4n/5) + n

  • T(n) <= 2T(n/2) + n

Question 5

A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size of 4 Kbytes. Each page table entry is of size 4 bytes. A three level page table is used for virtual to physical address translation, where the virtual address is used as follows 
• Bits 30-31 are used to index into the first level page table 
• Bits 21-29 are used to index into the second level page table 
• Bits 12-20 are used to index into the third level page table, and 
• Bits 0-11 are used as offset within the page 
The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first, second and third level page tables are respectively.

  • 20, 20 and 20

  • 24, 24 and 24

  • 24, 24 and 20

  • 25, 25 and 24

Question 6

Which of the following statements about synchronous and asynchronous I/O is NOT true?

  • An ISR is invoked on completion of I/O in synchronous I/O but not in asynchronous I/O

  • In both synchronous and asynchronous I/O, an ISR (Interrupt Service Routine) is invoked after completion of the I/O

  • A process making a synchronous I/O call waits until I/O is complete, but a process making an asynchronous I/O call does not wait for completion of the I/O

  • In the case of synchronous I/O, the process waiting for the completion of I/O is woken up by the ISR that is invoked after the completion of I/O

Question 7

The data blocks of a very large file in the Unix file system are allocated using

  • contiguous allocation

  • linked allocation

  • indexed allocation

  • an extension of indexed allocation

Question 8

For a magnetic disk with concentric circular tracks, the seek latency is not linearly proportional to the seek distance due to

  • non-uniform distribution of requests

  • arm starting and stopping inertia

  • higher capacity of tracks on the periphery of the platter

  • use of unfair arm scheduling policies

Question 9

What is printed by the following C program?

C
$include <stdio.h>
int f(int x, int *py, int **ppz)
{
  int y, z;
  **ppz += 1; 
   z  = **ppz;
  *py += 2;
   y = *py;
   x += 3;
   return x + y + z;
}
 
void main()
{
   int c, *b, **a;
   c = 4;
   b = &c;
   a = &b; 
   printf( "%d", f(c,b,a));
   getchar();
}
  • 18

  • 19

  • 21

  • 22

Question 10

1) Let R and S be two relations with the following schema
R (P,Q,R1,R2,R3)
S (P,Q,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?

  • Only I and II

  • Only I and III

  • Only I, II and III

  • Only I, III and IV

Tags:

There are 85 questions to complete.

Take a part in the ongoing discussion