Computer Hardware Review (Memory Hierarchy)
Chapter 1.4
Learning Outcomes
• Understand the concepts of memory hierarchy and caching, and how they affect performance.
2
Operating Systems
• Exploit the hardware available
• Provide a set of high-level services that represent or are implemented by the hardware.
• Manages the hardware reliably and efficiently
• Understanding operating systems requires a basic understanding of the underlying hardware
3
Memory Hierarchy
• Going down the hierarchy
• Decreasing cost per bit • Increasing capacity
• Increasing access time
• Decreasing frequency of access to the memory by the processor
• Hopefully
• Principle of locality!!!!!
4
Caching as a general technique
• Given two-levels of data storage: small and fast, versus large and slow,
• Can speed access to slower storage by using intermediate-speed storage as a cache.
5
A hardware approach to improving system performance?
CPU Registers Fast
Cache Memory (SRAM) Fast
Main Memory (DRAM) Slow
6
CPU Cache
Word Transfer Block Transfer
CPU Registers
Cache Memory
Main Memory
• CPU cache is fast memory placed between the CPU and main memory
• 1 to a few cycles access time compared to RAM access time of tens – hundreds
of cycles
• Holds recently used data or instructions to save memory accesses. • Matches slow RAM access time to CPU speed if high hit rate
• Is hardware maintained and (mostly) transparent to software
• Sizes range from few kB to tens of MB.
• Usually a hierarchy of caches (2–5 levels), on- and off-chip.
7
Performance
• What is the effective access time of memory subsystem?
• Answer: It depends on the hit rate in the first level.
8
Effective Access Time
Teff HT1(1H)T2
T1 access time of memory1 T 2 access time of memory 2
H hitrateinmemory1
Teff effective access time of system
9
Example
• Cache memory access time 1ns • Main memory access time 10ns • Hit rate of 95%
Teff 0.95109 (10.95)(109 10109) 1.5109
10
Moving-Head Disk Mechanism
11
Example Disk Access Times
• Disk can read/write data relatively fast • 15,000 rpm drive – 80 MB/sec
• 1 KB block is read in 12 microseconds
• Access time dominated by time to locate the head over data
• Rotational latency
• Half one rotation is 2 milliseconds
• Seek time
• Full inside to outside is 8 milliseconds • Track to track .5 milliseconds
• 2 milliseconds is 164KB in “lost bandwidth”
12
A OS approach to improving system performance?
CPU Registers Fast
Main Memory (DRAM) Fast
Hard disk Slow…
13
A Strategy: Avoid Waiting for Disk Access • Keep a subset of the disk’s data in main memory
⇒ OS uses main memory as a cache of disk contents
14
Application approach to improving system performance
Web browser Fast
Hard disk Fast
Internet Slow…
15
A Strategy: Avoid Waiting for Internet Access
• Keep a subset of the Internet’s data on disk
⇒ Application uses disk as a cache of the Internet
16