GATE 2013
80 questions
MCQ 801-mark 38 · 2-mark 42
Questions 21–25 of 80
A RAM chip has a capacity of 1024 words of 8 bits each (1K x 8). The number of 2 x 4 decoders with enable line needed to construct a 16K x 16 RAM from 1K x 8 RAM is
Answer: (B)
To build 16K 16 memory, we need 16 rows of chips. Each row has 2 chips to give 16 bits. To pick one row, we need a 4-to-16 decoder.
Make it from 24 decoders: 4 decoders give the 16 outputs, and 1 more decoder enables them. This gives 5.
Answer: 5
Make it from 24 decoders: 4 decoders give the 16 outputs, and 1 more decoder enables them. This gives 5.
Answer: 5
In a k-way set associative cache, the cache is divided into v sets, each of which consists of k lines. The lines of a set are placed in sequence one after another. The lines in set s are sequenced before the lines in set (s+1). The main memory blocks are numbered 0 onwards. The main memory block numbered j must be mapped to any one of the cache lines from
Answer: (A)
Main memory block j is placed in set j mod v. The cache lines of set s start at sk and go up to sk + (k 1).
Answer: (j mod v)*k to (j mod v)*k + (k1)
Answer: (j mod v)*k to (j mod v)*k + (k1)
Consider a hard disk with 16 recording surfaces (0-15) having 16384 cylinders (0-16383) and each cylinder contains 64 sectors (0-63). Data storage capacity in each sector is 512 bytes. Data are organized cylinder-wise and the addressing format is (cylinder no., surface no., sector no.). A file of size 42797 KB is stored in the disk and the starting disk location of the file is (1200, 9, 40). What is the cylinder number of the last sector of the file, if it is stored in a contiguous manner?
Answer: (D)
Work through each step:
- Sectors in one cylinder = 16 64 = 1024
- File size = 42797 KB / 0.5 KB = 85594 sectors
- The file starts at (1200, 9, 40). This is sector number 9 64 + 40 = 616 in cylinder 1200. So 1024 616 = 408 sectors are left in that cylinder.
- Sectors still to place = 85594 408 = 85186. This is 83 full cylinders (1201-1283) plus 194 sectors.
So the last sector lies in cylinder 1284.
Answer: 1284
- Sectors in one cylinder = 16 64 = 1024
- File size = 42797 KB / 0.5 KB = 85594 sectors
- The file starts at (1200, 9, 40). This is sector number 9 64 + 40 = 616 in cylinder 1200. So 1024 616 = 408 sectors are left in that cylinder.
- Sectors still to place = 85594 408 = 85186. This is 83 full cylinders (1201-1283) plus 194 sectors.
So the last sector lies in cylinder 1284.
Answer: 1284
Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction
(FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and Write Operand
(WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns and 6 ns, respectively. There are intermediate storage buffers after each stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions I1, I2, I3,..., I12 is executed in this pipelined processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the execution of this program, the time (in ns) needed to complete the program is
Answer: (B)
The clock period is the slowest stage plus the buffer delay: 10 + 1 = 11 ns.
I1, I2, I3 and I4 enter FI in cycles 1, 2, 3 and 4. So I4 is in FI in cycle 4, DI in 5, FO in 6 and EI in 7. The branch is known at the end of EI, cycle 7.
Instructions I5 to I8 are not run. The target I9 is fetched in cycle 8.
I9 goes through FI, DI, FO, EI and WO in cycles 8 to 12, which is 4 cycles after its fetch cycle. I10, I11 and I12 then finish one cycle after each other, in cycles 13, 14 and 15. So the last cycle is 8 + 4 + 3 = 15.
Total time = 15 11 = 165 ns
Answer: (B)
I1, I2, I3 and I4 enter FI in cycles 1, 2, 3 and 4. So I4 is in FI in cycle 4, DI in 5, FO in 6 and EI in 7. The branch is known at the end of EI, cycle 7.
Instructions I5 to I8 are not run. The target I9 is fetched in cycle 8.
I9 goes through FI, DI, FO, EI and WO in cycles 8 to 12, which is 4 cycles after its fetch cycle. I10, I11 and I12 then finish one cycle after each other, in cycles 13, 14 and 15. So the last cycle is 8 + 4 + 3 = 15.
Total time = 15 11 = 165 ns
Answer: (B)
What is the return value of f(p,p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value.
int f (int &x, int c) {
c = c - 1;
if (c==0) return 1;
x = x + 1;
return f(x,c) * x;
} Answer: (B)
Here x is the same variable as p, because it is passed by reference. c is only a copy. Every call adds 1 to x before it recurses. It multiplies by x only after the call returns.
The value of p changes like this: 5 6 7 8 9. After that c becomes 0 and the call returns 1. While returning, each of the 4 levels multiplies by x, and x is now 9.
Result:
Answer: 6561
The value of p changes like this: 5 6 7 8 9. After that c becomes 0 and the call returns 1. While returning, each of the 4 levels multiplies by x, and x is now 9.
Result:
Answer: 6561