GATE 2022
65 questions
MCQ 32 · MSQ 15 · NAT 181-mark 30 · 2-mark 35
Questions 61–65 of 65
A processor operating at 2 GHz has a standard 5-stage RISC instruction pipeline having a base CPI (cycles per instruction) of one without any pipeline hazards. For a given program P that has 30% branch instructions, control hazards incur 2 cycles stall for every branch. A new version of the processor operating at same clock frequency has an additional branch predictor unit (BPU) that completely eliminates stalls for correctly predicted branches. There is neither any savings nor any additional stalls for wrong predictions. There are no structural hazards and data hazards for and . If the BPU has a prediction accuracy of 80%, the speed up (rounded off to two decimal places) obtained by over in executing P is
Answer: 1.42 to 1.45
Find the CPI of each processor and compare them:
- : CPI
- : stalls happen only for the 20% of branches that are predicted wrongly: CPI
The clock is the same for both, so the speedup
Answer: 1.43
- : CPI
- : stalls happen only for the 20% of branches that are predicted wrongly: CPI
The clock is the same for both, so the speedup
Answer: 1.43
Consider the queues Q1 containing four elements and Q2 containing none (shown as the Initial State in the figure). The only operations allowed on these two queues are and . The minimum number of operations on Q1 required to place the elements of Q1 in Q2 in reverse order (shown as the Final State in the figure) without using any additional storage is
Answer: 0
Do the whole reversal with Q2 only. Each time a new element goes into Q2, move the older elements behind it by dequeuing from Q2 and enqueuing back into Q2.
- Move 1: element 1 Q2 gives [1]
- Move 2: element 2 Q2 gives [1, 2]. Rotate once [2, 1]
- Move 3: element 3 Q2. Rotate twice [3, 2, 1]
- Move 4: element 4 Q2. Rotate 3 times [4, 3, 2, 1]
Q1 is only dequeued. It is never enqueued.
Answer: 0
- Move 1: element 1 Q2 gives [1]
- Move 2: element 2 Q2 gives [1, 2]. Rotate once [2, 1]
- Move 3: element 3 Q2. Rotate twice [3, 2, 1]
- Move 4: element 4 Q2. Rotate 3 times [4, 3, 2, 1]
Q1 is only dequeued. It is never enqueued.
Answer: 0
Consider two files systems A and B , that use contiguous allocation and linked allocation, respectively. A file of size 100 blocks is already stored in A and also in
B. Now, consider inserting a new block in the middle of the file (between block), whose data is already available in the memory. Assume that there are enough free blocks at the end of the file and that the file control blocks are already in memory. Let the number of disk accesses required to insert a block in the middle of the file in A and B are and , respectively, then the value of is
Answer: 153
Contiguous (A): Blocks 51-100 each shift by one place. That is a read and a write for 50 blocks = 100 accesses. Writing the new block adds 1. .
Linked (B): Reach block 50 by following pointers = 50 reads. Write the new block, pointing to block 51 = 1. Rewrite the pointer of block 50 = 1. .
Answer: 153
Linked (B): Reach block 50 by following pointers = 50 reads. Write the new block, pointing to block 51 = 1. Rewrite the pointer of block 50 = 1. .
Answer: 153
Consider a demand paging system with four page frames (initially empty) and LRU page replacement policy. For the following page reference string
7, 2, 7, 3, 2, 5, 3, 4, 6, 7, 7,1, 5, 6,1
the page fault rate, defined as the ratio of number of page faults to the number of memory accesses (rounded off to one decimal place) is
7, 2, 7, 3, 2, 5, 3, 4, 6, 7, 7,1, 5, 6,1
the page fault rate, defined as the ratio of number of page faults to the number of memory accesses (rounded off to one decimal place) is
Answer: 0.6
Use LRU with 4 frames (F = fault):
7 F, 2 F, 7 hit, 3 F, 2 hit, 5 F [7, 2, 3, 5], 3 hit,
4 F (remove 7), 6 F (remove 2), 7 F (remove 5), 7 hit, 1 F (remove 3), 5 F (remove 4), 6 hit, 1 hit.
There are 9 faults in 15 references. So the fault rate
Answer: 0.6
7 F, 2 F, 7 hit, 3 F, 2 hit, 5 F [7, 2, 3, 5], 3 hit,
4 F (remove 7), 6 F (remove 2), 7 F (remove 5), 7 hit, 1 F (remove 3), 5 F (remove 4), 6 hit, 1 hit.
There are 9 faults in 15 references. So the fault rate
Answer: 0.6
Consider the following grammar along with translation rules.
Here and are operators and is a token that represents an integer and represents the corresponding integer value. The set of non-terminals is and a subscripted non-terminal indicates an instance of the non-terminal.
Using this translation scheme, the computed value of for root of the parse tree for the expression is
Here and are operators and is a token that represents an integer and represents the corresponding integer value. The set of non-terminals is and a subscripted non-terminal indicates an instance of the non-terminal.
Using this translation scheme, the computed value of for root of the parse tree for the expression is
Answer: 80
Look at the grammar. The operator # (multiply) comes at the S level, so it has lower precedence. The operator % (divide) comes at the T level, so it binds tighter. Both rules are left recursive, so both operators are left associative.
Evaluate the expression:
Answer: 80
Evaluate the expression:
Answer: 80