COMP2120-Assignment3
File description: Assignment 3 of COMP2120 (24/25 Spring) with solutions.
Document status: LTS
Last modified: 2026-09-11 21:12 HKT
COMP2120 Computer Organisation
24/25 Semester 2
Assignment 3
1. Consider a hypothetical machine with 1K words of cache memory. They are in a two-way set associative organisation, with a
cache block size of 128 words, using LRU replacement algorithm. Suppose the cache hit time is 10 ns, the time to transfer the
first word from main memory to cache is 60 ns, while subsequent words require 12 ns/word.
Consider the following read pattern (in blocks of 128 words, and block ID starts from 0), and assume each block has 48 refer-
ences:
1 2 3 5 6 2 3 4 9 10 11 6 3 6 1 7 8 4 5 9 11 1 2 4 5 12 13 14 15 13 14
(a) What is the cache miss penalty (i.e., time to transfer one block of data from main memory to cache memory)?
Solution:
Cache miss penalty = 60 + 12 × 127
= 1584 ns
(b) Write down the content of the cache memory (for all the blocks) at the end of the memory references, assuming that the
cache is empty at the beginning.
Solution: Content of the cache memory at the end of the memory references:
Set 0 Set 1 Set 2 Set 3
4 13 14 11
12 5 2 15
(c) Write down the number of cache misses (the first reading of a block is also considered a miss), and the cache hit rate.
Solution: Number of cache misses: 23
Number of blocks accessed = 31
Number of memory access = 31 × 48 = 1488
Hit rate = 1 −
23
1488
= 98.45%
(d) Calculate the average memory access time.
Solution: Average memory access time = 10 +(1 − 0.9845)× 1584 = 34.55 ns
2. Repeat Question 1 for a direct-mapped cache organisation with the cache hit time being 9 ns. All other parameters remain the
same.
Solution:
(a) Since the time to transfer the first block and subsequent blocks is the same, the cache miss penalty is the same, 1584 ns .
(b) Content of the cache memory at the end of the memory references:
Line 0 Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7
8 1 2 11 12 13 14 15
(c) Number of cache misses: 21
Number of blocks accessed = 31
Number of memory access = 31 × 48 = 1488
Hit rate = 1 −
21
1488
= 98.59%
(d) Average memory access time = 9 +(1 − 0.9859)× 1584 = 31.35 ns
Page 1 of 2
Page 1 of 2
3. Consider a Hard Disk with an average seek time of 12 ms and rotation speed of 7200 rpm, and an average number of 500 sectors
per track. Assume negligible transfer time.
(a) What is the average rotation latency?
Solution: Average rotation latency is given by:
1 min
7200 rotations
×
1
2
rotation × 60
seconds
minute
× 1000
ms
second
= 4.17 ms
(b) What is the average time to rotate for 1 sector?
Solution: Average time to rotate for one sector is given by:
1 min
7200 rotations
× 60
seconds
minute
× 1000
ms
second
×
1 rotation
500 sectors
= 0.0167 ms per sector
(c) Consider the access of 5 sectors. Caculate the time required (ignoring tranfer time, but including rotation time for reading a
sector) if
(1) The sectors are consecutive in the same track.
Solution: Time required to access 5 consecutive sectors = 4.17 + 12 + 0.0167 × 5 = 16.25 ms
(2) The sectors are scattered in various places in the HDD.
Solution: Time required to access 5 scattered sectors = 5 × (4.17 + 12 + 0.0167) = 80.93 ms
Page 2 of 2
Page 2 of 2
See also
-
COMP2120-Assignment1
Assignment 1 of COMP2120 (24/25 Spring) with solutions.
-
COMP2120-Assignment2
Assignment 2 of COMP2120 (24/25 Spring) with solutions.
-
COMP2120-Assignment4
Assignment 4 of COMP2120 (24/25 Spring) with solutions.
-
COMP2120-Assignment5
Assignment 5 of COMP2120 (24/25 Spring) with solutions.
-
COMP2120-Cheatsheet
An A4 double-sided cheatsheet for the COMP2120 final exam.
-
COMP2120-Notes
Revision notes for COMP2120.