1
GATE CSE 2012
MCQ (Single Correct Answer)
+1
-0.3
A process executes the code
fork $$\left( {\,\,\,} \right);$$
fork $$\left( {\,\,\,} \right);$$
fork $$\left( {\,\,\,} \right);$$
The total number of child processes created is
A
$$3$$
B
$$4$$
C
$$7$$
D
$$8$$
2
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
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

A
$$FCFS:P1,P2,P3\,\,\,\,RR2:P1,P2,P3$$
B
$$FCFS:P1,P3,P2\,\,\,\,RR2:P1,P3,P2$$
C
$$FCFS:P1,P2,P3\,\,\,\,RR2:P1,P3,P2$$
D
$$FCFS:P1,P3,P2\,\,\,\,RR2:P1,P2,P3$$
3
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
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; 
} 
Release Lock(L){ 
  L = 0; 
}
This implementation
A
fails as L can overflow
B
fails as L can take on a non-zero value when the lock is actually available
C
works correctly but may starve some processes
D
works correctly without starvation
4
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C code segment.
int a, b, c = 0;
void prtFun(void);
main( )
{ 
   static int a = 1; /* Line 1 */
   prtFun();
   a + = 1;
   prtFun();
   printf("\n %d %d ", a, b);
}
void prtFun(void)
{ 
   static int a=2;   /* Line 2 */
   int b=1;
   a+ = ++b;
   printf("\n %d %d ", a, b);
}
What output will be generated by the given code segment?
A
$$\eqalign{ & 3\,\,1 \cr & 4\,\,1 \cr & 4\,\,2 \cr} $$
B
$$\eqalign{ & 4\,\,2 \cr & 6\,\,1 \cr & 6\,\,1 \cr} $$
C
$$\eqalign{ & 4\,\,2 \cr & 6\,\,2 \cr & 2\,\,0 \cr} $$
D
$$\eqalign{ & 3\,\,1 \cr & 5\,\,2 \cr & 5\,\,2 \cr} $$
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