Docsity

CS232 Fall 2006 Midterm Exam 3 Solutions: I/O, Caches, Memory Interleaving, Virtual Memory, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
CS232 Fall 2006 Midterm Examination 3 November 29, 2006
1. I/O: A hard disk has the following features:
•Rotational speed = 10,000 RPM
•Average seek time = 7 ms
•Data can be written as fast as the disk rotates
•Each sector holds 512 bytes of data, each track has 1000 sectors
(a) What is the average time to write 4 MB of data to the disk assuming that sectors available for writing
are spread randomly on the disk? Explain your answer. 9 points
Solution: For each sector, we perform:
Seek: 7 ms (average)
Rotation: 0.5rotation
10000 rotation
minute ×1minute
60000 ms
= 3 ms (average)
Transfer: 1sector
1000 sectors
track ×1track
rotation×10000 rotations
minute ×1minute
60000 ms
= 0.006 ms
File size = 4 MB = 4×1024×1024 bytes
512 bytes/sector = 8192 sectors.
Hence, the total time required is 8192 ×(7+3+0.006) ms .
(b) If the bus supplying data to the disk has a bandwidth of 60 KB/s, what is the bottleneck for the above
write operation: the bus or the hard disk? Explain your answer. 2 points
Solution: The average rate at which data is written to the disk is 512 bytes/sector
10.006 ms/sector '50 KB/s. Since
this is less than the bandwidth of the bus, the disk is the bottleneck.
2. Caches: A byte addressable two-level cache is accessed using 20-bit addresses.
(a) The L1 cache has a write-through policy, size = 128 KB, block size = 32 bytes, and implements full
LRU using just one LRU bit per set. Compute the length of the block-offset, index and tag. Explain
your answer. 6 points
Solution: 128 KB= 217 bytes data, 32 = 25bytes per block.
Hence, 5-bit block offset , 217
25= 212 blocks.
Full associativity and one LRU bit per set, hence 2-way set associative.
Thus, 212/2 = 211 sets, i.e. 11-bit index .
20-bit address, therefore 20 −11 −5 = 4-bit tag .
1
pf3
pf4

Partial preview of the text

Download CS232 Fall 2006 Midterm Exam 3 Solutions: I/O, Caches, Memory Interleaving, Virtual Memory and more Exams Computer Architecture and Organization in PDF only on Docsity!

  1. I/O: A hard disk has the following features:
    • Rotational speed = 10,000 RPM
    • Average seek time = 7 ms
    • Data can be written as fast as the disk rotates
    • Each sector holds 512 bytes of data, each track has 1000 sectors

(a) What is the average time to write 4 MB of data to the disk assuming that sectors available for writing are spread randomly on the disk? Explain your answer. 9 points

Solution: For each sector, we perform: Seek: 7 ms (average) Rotation: (^10000) rotation^0.^5 rotation minute ×^

1 minute 60000 ms

= 3 ms (average)

Transfer: (^1000) sectors^1 sector track ×^

1 track rotation ×^

10000 rotations minute ×^

160000 minute ms = 0.006 ms

File size = 4 MB = 4512 ×^1024 bytes/sector×^1024 bytes = 8192 sectors.

Hence, the total time required is 8192 × (7 + 3 + 0.006) ms. (b) If the bus supplying data to the disk has a bandwidth of 60 KB/s, what is the bottleneck for the above write operation: the bus or the hard disk? Explain your answer. 2 points

Solution: The average rate at which data is written to the disk is (^51210). 006 bytes/sector ms/sector ' 50 KB/s. Since this is less than the bandwidth of the bus, the disk is the bottleneck.

  1. Caches: A byte addressable two-level cache is accessed using 20-bit addresses.

(a) The L1 cache has a write-through policy, size = 128 KB, block size = 32 bytes, and implements full LRU using just one LRU bit per set. Compute the length of the block-offset, index and tag. Explain your answer. 6 points Solution: 128 KB= 2^17 bytes data, 32 = 2^5 bytes per block. Hence, 5-bit block offset , 2 17 25 = 2

(^12) blocks. Full associativity and one LRU bit per set, hence 2-way set associative. Thus, 2^12 /2 = 2^11 sets, i.e. 11-bit index. 20-bit address, therefore 20 − 11 − 5 = 4-bit tag.

(b) The L2 cache has a write-back policy, size = 256 KB, 4-way set associative, 8-bit block offset, 8-bit index, 4-bit tag and implements full LRU. Initially, both caches are empty (i.e. all data is invalid). Construct five distinct addresses a 1 , a 2 ,... , a 5 such that after reading each address exactly once, the L1 cache holds valid data for address a 1 whereas the L2 cache does not. Explain your answer. 6 points

Hint: Choose addresses that map to the same set in the L2 cache. Use the fact that the L2 cache is 4-way set associative. You do not have to write out the addresses, but you must describe them clearly.

Solution: The 20-bit addresses are decomposed as follows for the two caches:

L1 cache: tag index offset L2 cache: tag index offset 4 8 8 Choose addresses a 1 ,... , a 5 that have all the following properties:

  • identical on the 8 L2 index bits
  • different on the 4 tag bits (possible, since there are 16 unique tags for both caches)
  • different on the 3 LSBs of the L1 cache (possible, since there are 8 unique such combinations) These addresses map to the same set in the L2 cache. Since the tag bits are unique, each address belongs to a unique block. Since the L2 cache is only 4-way set associative, the block containing a 1 is evicted from L after the block containing a 5 is read. (Note that L2 is accessed on all these addresses, since L1 is initially empty.) However, these addresses map to different sets in the L1 cache (since they have different L1 index bits), and hence all blocks containing these addresses are in the L1 cache after the access sequence a 1 ,... , a 5.
  1. Interleaved Memory

Consider an interleaved memory with 2 banks, each with a latency of 3 cycles. The cache-to-memory bus has width = 4 bytes, latency = 1 cycle and has multiplexed address and data lines. Each cache block holds 16 bytes. To transfer data between the cache and memory (in either direction), a 4-byte address must be sent to each bank individually over the bus.

(a) Use the table below to show how a dirty cache-block can be written to memory in at most 11 cy- cles. 2 points

1 2 3 4 5 6 7 8 9 10 11 12 A D L L L A D L L L A D L L L A D L L L Here, A = address, D = data, L = latency (of the bank) (b) Use the table below to show how a clean cache-block can be replaced with a block from memory in at most 12 cycles. For full credit, show that it can be done in 11 cycles. 5 points

1 2 3 4 5 6 7 8 9 10 11 12 A L L L D A L L L D

  • A L L L D A L L L D
  • Without this stall, we have a structural hazard in cycle 4 with the first bank.

(d) A two-tier page table and a two-level page table are designed so that both require the same amount of memory. Explain one advantage and one disadvantage of the two-tier page table. 2 points Advantage: Only one memory access is needed to retrieve the PPN in the best case (i.e. a hit in T 1 ) – a two-level page-table always needs at least two memory accesses. Disadvantage: T 1 stores only one PPN per entry, hence it is “direct mapped”. Thus, there is a conflict between any two virtual addresses that map to the same entry in T 1. Hence, it is very easy to get worst-case behavior (i.e. expensive disk access) in a two-tier cache.

If you asked for a conflict, please email me with details!

[email protected]