Beruflich Dokumente
Kultur Dokumente
Lakshman Jayaratne
Learning Objectives
§ Primary/Main memory
Ø Highest speed
Ø Most expensive, therefore smallest
Ø Typically solid state technology (transistors)
§ Secondary memory
Ø Lower speed
Ø Less expensive, therefore can be larger
Ø Typically magnetic media and electro-
electro-
mechanical drive mechanism
Types of Main Memory
§ ROM – Read Only Memory
Ø Non
Non--volatile, read-
read-only
Ø Variants of ROM
o PROM (Programmable Read Only Memory)
o EEPROM (Electrically Erasable PROM)
SRAM
Fast
3-30 ns
Accessing Data
§ Size
§ Write Policy (write through, write back)
§ Type (directly mapped, set associative)
Ø line replacement policy
§ Disadvantage
Ø Inefficient in bus traffic
Write Back Policy
§ Disadvantage
Ø Memory doesn’t always agree with the value in the
cache
Types of Caches
§ Directly mapped
§ Set associative
§ (Fully associative)
20
Directly Mapped Cache
Memory Address
High Bits Low Bits
0x000 0x10020 1 25
Valid Bit
0x010
Low Order Address Bits
Cache Tag Memory Cache Data Memory
A 0... A C-1 0x014
0x018
Memory Address 0x01c
0x10020
Bits Low004
.
High Bits .
.
High Order Address Bits Hit or Miss ?
A C... A N-1 Comparator
Directly Mapped Cache – Note (I)
§ Disadvantage
Ø If a program frequently accesses two locations
which have the same LOABs and different
HOABs, then for every access the cache will
overwrite the previous entry
Set Associative Cache
§ Advantage
Ø Achieve good hit ratios despite being smaller in
size
2-Way Set Associative Cache
Memory Address
High Bits Low Bits
Fast Slow
If address not in MMU,
execute software to
fetch from disk into
MISS memory, and update
Virtual Address
Extremely Slow
Memory
Cache
Physical Address
Pages Page
0 2 Frames
1 - 0 Physical
2 - 1
Virtual 3 0 Memory
Memory 2
4 1
5 - 3
6 -
7 3
Terminology
Execution is interleaved
Finding out where a Referenced
Address is
Through a Page Table, which stores the
physical location of each Virtual Page (VP) page not
in main
memory
2
3
0 page in
2 main
memory
Calculating an Address in Physical
Memory
§ Dividing memory into blocks enables an address to
be divided into two parts
Ø High
High--order bits – contain the address of a page (or
page frame)
Ø Low
Low--order bits – contain the address of a word
inside the page
High-order bits Low-order bits
MISS
Virtual Address
MMU
HOAB:
HOAB
->31…12
13 ... 31
Cache
Memory
CPU
TLB
Management Page #2
Unit
Page Size
HIT Physical Address Page #1 2^12 , 4096
Page Select Bytes
HOAB
HOAB: ->31…12
12 ... 31
Word Select Page #0
LOAB ->11…0
LOAB: 0 ... 11
00000100110010001010 Megabytes - Gigabytes
Virtual to Physical Address Mapping
Slow
Virtual to Physical Address Mapping Main Memory
Page #N
Number of Pages = 2^Q
Q Bits P Bits
Page #2
HOAB LOAB
0000 0100 1010 1101 0011 1001 0110
Translating a VA into a PA - Example
Segment #1
Segment Table
SIZE ADDRESS
Segment Size
== Variable
Segment #42 Number of
Bytes
Segment #7
Segment #13
Segment Table
§ Presence in memory
Ø In a paged VM system, only portions of a
file need be in memory at any time, the rest
may be on disk
Ø In a segmented VM system, the whole file
must be in memory at any time
§ Each segment and page must always be
smaller than the physical memory
§ Segment Tables are usually smaller than
Page Tables
Hybrid VM Systems
1. Type of block
• Fixed size – Paging
o Large pages are better
o May cause Internal Fragmentation
• Variable size – Segmentation
o May cause External Fragmentation
• Hybrid
2. Virtual to physical address mapping
• Use Page/Segment Table
o Employ TLB (Translation Look-
Look-aside
Buffer)
Thank You
SCS1003 - Computer
Systems