GATE Solved Paper 2017-19 - GATE 2018

32. Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is N. Three semaphores empty, full and mutex are defined with respective initial values of 0, N and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait ( ) and signal ( ).

 Producer Consumer
  do{
  wait(p);
  wait(mutex);
  //Add item to buffer
  signal(mutex);
  signal(Q);
}while (1);
 do{
  wait(R);
  wait(mutex);
  //Consume item from buffer
  signal (mutex);
  signal ();
}while (1);
 Which one of the following assignments to P, Q, R and S will yield the correct solution?

  • Option : C
  • Explanation :
    Full = N, empty = 0, mutex = 1
    Initially buffer will be empty, so consumer should not start first, so options B, D are eliminated.
    With option A consumer will never consume the item, so it is wrong.
    Option ‘C’ is the correct answer which proper functionality of produce and consumer.
Cancel reply
Cancel reply

35. Let N be the set of natural numbers. Consider the following sets:
P. Set of rational numbers (positive and negative).
Q. Set of functions from {0, 1} to N.
R. Set of functions from N to {0, 1}.
S. Set of finite subsets of N.
Which of the sets above are countable?

  • Option : D
  • Explanation :
    P : Set of rational number → countable
    Q : Set of functions from {0, 1} to N → N

    0 can be assigned in N ways
    1 can be assigned in N ways
    There are functions, cross product of countable set in countable.
    R : Set of functions from N to {0, 1}

    Each of thus boxes can be assigned to 0 or 1 so each such function is a binary number with infinite number of bits.
Cancel reply
Cancel reply