GATE 2016 (Session 2)
65 questions
MCQ 38 · NAT 271-mark 30 · 2-mark 35
Questions 56–60 of 65
A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10][3];
The grammars use D as the start symbol,and use six terminal symbols int ;id[]num.
Which of the grammars correctly generate the declaration mentioned above?
int a[10][3];
The grammars use D as the start symbol,and use six terminal symbols int ;id[]num.
Grammar G1 Grammar G2
D → int L; D → int L;
L → id [E L → id E
E → num] E → E[num]
E → num] [E E → [num] Which of the grammars correctly generate the declaration mentioned above?
Answer: (A)
We derive int a[10][3]; using each grammar in turn.
- G1: D int L; int id [ E ; int id [ num ] [ E ; int id [num] [num] ; This is accepted.
- G2: D int L; int id E ; int id E [num] ; int id [num] [num] ; This is accepted.
In general, both grammars also generate arrays with one or more dimensions.
Answer: Both G1 and G2
- G1: D int L; int id [ E ; int id [ num ] [ E ; int id [num] [num] ; This is accepted.
- G2: D int L; int id E ; int id E [num] ; int id [num] [num] ; This is accepted.
In general, both grammars also generate arrays with one or more dimensions.
Answer: Both G1 and G2
Consider the following processes, with the arrival time and the length of the CPU burst given in milli seconds.The scheduling algorithm used is preemptive shortest remaining-time first.
The average turn around time of these processes is milliseconds.
The average turn around time of these processes is milliseconds.
Answer: 8.2 to 8.3
SRTF: P1 runs 0-3 (7 left). P2 arrives (6 7) and runs 3-7 (2 left). P3 (1) runs 7-8. P2 runs 8-10. P4 runs 10-13. P1 runs 13-20.
Turnaround: P1 is 20, P2 is 10 3 = 7, P3 is 8 7 = 1, P4 is 13 8 = 5.
Average = 33 / 4 = 8.25
Answer: 8.25
Turnaround: P1 is 20, P2 is 10 3 = 7, P3 is 8 7 = 1, P4 is 13 8 = 5.
Average = 33 / 4 = 8.25
Answer: 8.25
Consider the following two-process synchronization solution.
The shared variable turn is initialized to zero.Which one of the following is TRUE?
Process 0 Process 1
--------- ----------
Entry: loop while (turn == 1); Entry: loop while (turn == 0);
(critical section) (critical section)
Exit: turn = 1; Exit: turn = 0;The shared variable turn is initialized to zero.Which one of the following is TRUE?
Answer: (C)
This solution is strict alternation. The two processes have to go in turns.
Mutual exclusion is satisfied. But take the case where process 0 wants to enter a second time and process 1 does not want to enter at all. Then process 0 has to wait, because turn = 1. It is held up by a process that is not even trying to enter. This breaks the progress requirement.
Answer: This solution violates progress requirement
Mutual exclusion is satisfied. But take the case where process 0 wants to enter a second time and process 1 does not want to enter at all. Then process 0 has to wait, because turn = 1. It is held up by a process that is not even trying to enter. This breaks the progress requirement.
Answer: This solution violates progress requirement
Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.
Answer: 7
Let the initial value of S be x. The 12 V operations add at most 12 more units, so at most x + 12 P operations can finish. If at least one of the 20 P operations must stay blocked, we need: .
Answer: 7
Answer: 7
A file system uses an in-memory cache to cache disk blocks.The miss rate of the cache is shown in the figure. The latency to read a block from the cache is 1 ms and to read a block from the disk is 10ms. Assume that the cost of checking whether a block exists in the cache is negligible. Available cache sizes are in multiples of 10MB.
The smallest cache size required to ensure an average read latency of less than 6ms is_________ MB.
The smallest cache size required to ensure an average read latency of less than 6ms is_________ MB.
Answer: 30
The average latency is (1 m) 1 + m 10 = 1 + 9m, where m is the miss rate. The condition we need is .
The graph shows that 20 MB gives a miss rate of 60%, which is too high. 30 MB gives 40% latency 1 + 3.6 = 4.6 ms. This is True.
Answer: 30
The graph shows that 20 MB gives a miss rate of 60%, which is too high. 30 MB gives 40% latency 1 + 3.6 = 4.6 ms. This is True.
Answer: 30