1
GATE CSE 2014 Set 2
MCQ (Single Correct Answer)
+2
-0.6
Consider the procedure below for the Producer-Consumer problem which uses semaphores:
semaphore n = 0;
semaphore s = 1;
void producer()
{
    while(true)
    {
     produce();
     semWait(s);
     addToBuffer();
     semSignal(s);
     semSignal(n);
    }
}
void consumer()
{
   while(true)
   {
    semWait(s);
    semWait(n);
    removeFromBuffer();
    semSignal(s);
    consume();
   }
}
Which one of the following is TRUE?
A
The producer will be able to add an item to the buffer, but the consumer can never consume it.
B
The consumer will remove no more than one item from the buffer.
C
Deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.
D
The starting value for the semaphore n must be 1 and not 0 for deadlock-free operation.
2
GATE CSE 2014 Set 2
Numerical
+2
-0
Three processes $$A, B$$ and $$C$$ each execute a loop of $$100$$ iterations. In each iteration of the loop, a process performs a single computation that requires $${t_c}\,\,CPU$$ milliseconds and then initiates a single $${\rm I}/O$$ operation that lasts for $${t_{io}}$$ milliseconds. It is assumed that the computer where the processes execute has sufficient number of $${\rm I}/O$$ devices and the $$OS$$ of the computer assigns different $${\rm I}/O$$ devices to each process. Also, the scheduling overhead of the $$OS$$ is negligible. The processes have the following characteristics:
Process id tc tio
A 100 ms 500 ms
B 350 ms 500 ms
C 200 ms 500 ms

The processes $$A, B,$$ and $$C$$ are started at times $$0, 5$$ and $$10$$ milliseconds respectively, in a pure time sharing system (round robin scheduling) that uses a time slice of $$50$$ milliseconds. The time in milliseconds at which process $$C$$ would complete its first $${\rm I}/O$$ operation is __________.

Your input ____
3
GATE CSE 2014 Set 2
Numerical
+1
-0
Consider the function func shown below:
int func(int num) 

{
         int count = 0;
         while(num)
         {
                count++;
                num >>= 1;
         }
  return (count);
}

The value returned by func(435) is _________.
Your input ____
4
GATE CSE 2014 Set 2
MCQ (Single Correct Answer)
+1
-0.3
Suppose n and p are unsigned int variables in a C program. We wish to set p to $${}^n{C_3}$$. If n is large, which one of the following statements is most likely to set p correctly?
A
$$p = n*(n - 1)*(n - 2)/6$$
B
$$p = n*(n - 1)/2*(n - 2)/3$$
C
$$p = n*(n - 1)/3*(n - 2)/2$$
D
$$p = n*(n - 1)*(n - 2)/6.0$$
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12