Memory Organisation in COA
Memory Organisation in COA
Memory Organization
Memory Hierarchy
Main Memory
Associative Memory
Virtual Memory
1
Memory Hierarchy
5
Main Memory
6
Main Memory
SRAM DRAM
Uses capacitor for storing Uses Flip flop
information
More cells per unit area due Needs more space for same
to smaller cell size. PD is less capacity. PD is more
Cheaper and smaller in size Expensive and bigger in size
Slower Faster
9
10
ROM Memory
11
Memory address Map
12
13
Recap of Last Lecture
Memory Hierarchy
Main Memory
14
Memory Connection with CPU
15
Associative Memory
16
Associative Memory
17
18
Associative Memory
19
Associative Memory
21
22
Match Logic
23
24
Match Logic
25
26
Read Operation
27
Write Operation
28
Cache Memory
L1 (Level 1) cache is the fastest memory that is present in a computer system. In terms of
priority of access, L1 cache has the data the CPU is most likely to need while completing a
certain task. As far as the size goes, the L1 cache typically goes up to 256KB. However, some
really powerful CPUs are now taking it close to 1MB. Some server chipsets (like Intel's top-end
Xeon CPUs) now have somewhere between 1-2MB of L1 cache.
L1 cache is also usually split two ways, into the instruction cache and the data cache. The
instruction cache deals with the information about the operation that the CPU has to perform,
while the data cache holds the data on which the operation is to be performed.
30
L2 (Level 2) cache is slower than L1 cache, but bigger in size. Its size typically varies
between 256KB to 8MB, although the newer, powerful CPUs tend to go past that. L2
cache holds data that is likely to be accessed by the CPU next. In most modern CPUs,
the L1 and L2 caches are present on the CPU cores themselves, with each core getting
its own cache.
L3 (Level 3) cache is the largest cache memory unit, and also the slowest one. It can
range between 4MB to upwards of 50MB. Modern CPUs have dedicated space on the
CPU die for the L3 cache, and it takes up a large chunk of the space.
31
Top View of Memory Organization in Computer System
L2 CACHE 1
L2 CACHE 0
SHARED L3 CACHE
DRAM INTERFACE
DRAM BANKS
CORE 0 CORE 1
DRAM MEMORY
L2 CACHE 2 CONTROLLER
L2 CACHE 3
CORE 2 CORE 3
32
Memory System: A Shared Resource View
Storage
33
A 64-bit Wide DRAM
34
Generalized Memory Structure
35
Basic Operation of Cache Memory
36
Example: Transferring a cacheblock
Physical memoryspace
0xFFFF…F
Channel 0
..
0x40
Rank 0
64B
cache block
0x00
Example: Transferring a cacheblock
Physical memoryspace
Chip 0 Chip 1 Chip 7
Rank 0
0xFFFF…F
...
..
.
<56:63
<8:15>
<0:7
>
>
0x40
64B
Data <0:63>
cache block
0x00
Example: Transferring a cacheblock
Physical memoryspace
Chip 0 Chip 1 Chip 7
Rank 0
0xFFFF…F
Row 0 ...
Col 0
..
.
<56:63
<8:15>
<0:7
>
>
0x40
64B
Data <0:63>
cache block
0x00
Example: Transferring a cacheblock
Physical memoryspace
Chip 0 Chip 1 Chip 7
Rank 0
0xFFFF…F
Row 0 ...
Col 0
..
.
<56:63
<8:15>
<0:7
>
>
0x40
64B
Data <0:63>
cache block
8B
0x00 8B
Example: Transferring a cache block
Physical memoryspace
Chip 0 Chip 1 Chip 7
Rank 0
0xFFFF…F
Row 0 ...
Col 1
..
.
<56:63
<8:15>
<0:7
>
>
0x40
64B
Data <0:63>
cache block
8B
0x00
Example: Transferring a cacheblock
Physical memoryspace
Chip 0 Chip 1 Chip 7
Rank 0
0xFFFF…F
Row 0 ...
Col 1
..
.
<56:63
<8:15>
<0:7
>
>
0x40
64B
8B Data <0:63>
cache block
8B
0x00 8B
Example: Transferring a cacheblock
Physical memoryspace
Chip 0 Chip 1 Chip 7
Rank 0
0xFFFF…F
Row 0 ...
Col 1
..
.
<56:63
<8:15>
<0:7
>
>
0x40
64B
8B Data <0:63>
cache block
8B
0x00
A 64B cache block takes 8 I/Ocycles to transfer.
44
Cache Memory Organisation
45
Associative Mapping
46
Associative Mapping
47
Associative Mapping
48
Direct Memory
49
50
Direct Mapping Cache Organization
51
Direct Mapping Cache Organization
52
Direct Mapping Cache Organization
53
54
Set-Associative Mapping
55
56
Set-Associative Mapping
When a miss occur and the set is full, one of the tag
data item is replaced with new value using various
algorithm.
57
Set- Associative Mapping
58
Virtual Memory
59
Virtual Memory
60
Address Space and Memory Space
61
Virtual Memory
62
63
Address Mapping Using Pages
64
65
66
67
Page Replacement
68
Writing into Cache
69
Cache Initialization
70
Background
CPU
Desirable
increasing
Demand paging
3045 / 2048 = 1
3045 % 2048 = 3045 - 2048 = 997
VP# = 1
Offset within page = 1007
Page Size is always a power of 2? Why?
Page Size Criteria
Executable
0 code space
1
2
3 LAS 0
4
5
6
7
Main memory LAS 1
(Physical Address Space -PAS)
LAS 2
LAS - Logical Address Space
Issues in demand paging
Multiprogramming level
Load control (contd.)
i
i
page table
Page Table When Some Pages Are
Not in Main Memory
Page Fault
- Copy-on-Write
Basic idea:
• if there is a free page in memory, use it
• if not, select a victim frame
• write the victim out to disk
• read the desired page into the now free frame
• update page tables
• restart the process
Page Replacement
Reference String
Reference string is the sequence of pages being
referenced
If user has the following sequence of addresses
123, 215, 600, 1234, 76, 96
If the page size is 100, then the reference string is
1, 2, 6, 12, 0, 0
First-In, First-Out (FIFO)
Compulsory Misses
0 4 4 4 4 2
2 4 2 0 0 3 0 1 0 2 0
1 1 1 3 3 3
6 6 6 6 1 1
Compulsory Misses
0 0 3
2 4 2 3 2
1 1 1
6 4 4
Basic idea
replace the page in memory that has not been accessed for the longest time
Optimal policy looking back in time
as opposed to forward in time
fortunately, programs tend to follow similar behavior
LRU
Compulsory Misses
0 4 4 4 2
2 4 2 0 0 3 0 2 0
1 1 1 1 1
6 6 6 3 3
Interrupt
R
0 0 10110011
1 0 01000100
2 0 01000000 page to replace
3 0 10101010 on next page fault
4 0 10000110
Clock Algorithm (Second Chance)
R R
P0 0 P6 1 0
Pointer to first
page to check
R
1 R
P9
P1 1 0