GATE 2014 (Session 1)
65 questions
MCQ 40 · NAT 251-mark 30 · 2-mark 35
Questions 41–45 of 65
An operating system uses the Banker's algorithm for deadlock avoidance when managing the allocation of three resource types X, Y, and Z to three processes P0, P1, and P2. The table given below presents the current system state. Here, the Allocation matrix shows the current number of resources of each type allocated to each process and the Max matrix shows the maximum number of resources of each type required by each process during its execution.
There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is currently in a safe state. Consider the following independent requests for additional resources in the current state:
REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z
REQ2: P1 requests 2 units of x, 0 units of Y and 0 units of Z
Which one of the following is TRUE?
There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is currently in a safe state. Consider the following independent requests for additional resources in the current state:
REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z
REQ2: P1 requests 2 units of x, 0 units of Y and 0 units of Z
Which one of the following is TRUE?
Answer: (B)
Need = Max Allocation. P0 (8,4,2), P1 (3,0,0), P2 (1,2,2). Available (3,2,2).
- REQ1 (P0 takes 0,0,2): available is (3,2,0). P1 can finish (6,4,0). Then P0 (needs X = 8) and P2 (needs Z = 2) both cannot run unsafe, deny.
- REQ2 (P1 takes 2,0,0): available is (1,2,2). P1 needs (1,0,0) finishes (6,4,2). P2 runs (8,5,3). P0 runs safe, grant.
Answer: Only REQ2 can be permitted
- REQ1 (P0 takes 0,0,2): available is (3,2,0). P1 can finish (6,4,0). Then P0 (needs X = 8) and P2 (needs Z = 2) both cannot run unsafe, deny.
- REQ2 (P1 takes 2,0,0): available is (1,2,2). P1 needs (1,0,0) finishes (6,4,2). P2 runs (8,5,3). P0 runs safe, grant.
Answer: Only REQ2 can be permitted
Consider the following set of processes that need to be scheduled on a single CPU. All the times are given in milliseconds
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ________.
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ________.
Answer: 7.2
SRTF always runs the process with the shortest remaining time, checked whenever a process arrives or finishes.
- t = 0-3: only A is present, so A runs (3 left).
- t = 3: B arrives with 2, which is less than A's 3, so B preempts A and runs 3-5.
- t = 5: B is done. C arrives with 4, but A has only 3 left, so A runs 5-8. D arrives at 7 with 6, which is more than A's 1 left, so there is no change.
- t = 8: A is done. C (4) is shorter than D (6), so C runs from 8. E arrives at 10 with 3, but C has only 2 left, so C is not preempted and finishes at 12.
- t = 12: E (3) is shorter than D (6), so E runs 12-15. Then D runs 15-21.
Schedule: A 0-3, B 3-5, A 5-8, C 8-12, E 12-15, D 15-21.
Turnaround time = completion arrival:
A = 8 0 = 8, B = 5 3 = 2, C = 12 5 = 7, D = 21 7 = 14, E = 15 10 = 5
Average = (8 + 2 + 7 + 14 + 5) / 5 = 36 / 5 = 7.2 ms
Answer: 7.2 ms
- t = 0-3: only A is present, so A runs (3 left).
- t = 3: B arrives with 2, which is less than A's 3, so B preempts A and runs 3-5.
- t = 5: B is done. C arrives with 4, but A has only 3 left, so A runs 5-8. D arrives at 7 with 6, which is more than A's 1 left, so there is no change.
- t = 8: A is done. C (4) is shorter than D (6), so C runs from 8. E arrives at 10 with 3, but C has only 2 left, so C is not preempted and finishes at 12.
- t = 12: E (3) is shorter than D (6), so E runs 12-15. Then D runs 15-21.
Schedule: A 0-3, B 3-5, A 5-8, C 8-12, E 12-15, D 15-21.
Turnaround time = completion arrival:
A = 8 0 = 8, B = 5 3 = 2, C = 12 5 = 7, D = 21 7 = 14, E = 15 10 = 5
Average = (8 + 2 + 7 + 14 + 5) / 5 = 36 / 5 = 7.2 ms
Answer: 7.2 ms
Assume that there are 3 page frames which are initially empty. If the page reference string 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6, the number of page faults using the optimal replacement policy is ______
Answer: 7
Use the optimal policy with 3 frames. On a fault, remove the page whose next use is furthest away in the future.
1 F, 2 F, 3 F, 4 F (remove 3), 2, 1, 5 F (remove 1), 3 F (remove 5), 2, 4, 6 F
Total faults = 7
Answer: 7
1 F, 2 F, 3 F, 4 F (remove 3), 2, 1, 5 F (remove 1), 3 F (remove 5), 2, 4, 6 F
Total faults = 7
Answer: 7
A canonical set of items is given below
S
QR.
On input symbol the set has
S
QR.
On input symbol the set has
Answer: (D)
Look at the item S L. R. It can shift only on the symbol "". So there is no shift on "". The set has only one complete item, Q R., so two reductions are not possible. There is no conflict on "".
Answer: neither a shift-reduce nor a reduce-reduce conflict
Answer: neither a shift-reduce nor a reduce-reduce conflict
Let L be a language and be its complement. Which of the following is NOT a viable possibility?
Answer: (C)
Suppose L and are both r.e. Then we can run their two recognizers at the same time, and this decides L. So L is recursive. This means the case "both r.e. but not recursive" cannot happen. The other three cases can happen.
Answer: Both L and are r.e. but not recursive
Answer: Both L and are r.e. but not recursive