08 - Memory Management
08 - Memory Management
Memory Management
Matti Juutilainen
Mikpoli MB317
[email protected]
8.11.2010
Computer Storage Hierarchy
Computers use a variety of
memory types, organized in a
storage hierarchy around the
CPU, as a trade-off between
performance and cost
The lower a storage is in the
hierarchy,
the lesser its bandwidth
the greater its access
latency is from the CPU
the lower its cost
Now we concentrate on
the main memory (RAM)
2
RAM and cache both store "active" data in (volatile) electronic circuitry
Cache uses faster, more expensive SRAM technology
Level-1 cache is stored directly on the CPU chip (runs at speeds
comparable to processor speed, ~10x RAM access speed common)
Level-2 cache is stored on the CPU chip or nearby chip
Common approach:
When data from RAM is needed by CPU, first copy into cache
CPU then accesses cache directly
Cache retains recently used (most active?) data, fast access if needed
again
11
0 0 0 0
OS OS OS OS
400K 400K 400K 400K
P1 P1 P1
1000K 1000K 1000K
P2
P4 …
1700K
2000K 2000K 2000K
P3 P3 P3
2300K 2300K 2300K
0
OS
400K
P1
process memory
1000K
first-fit is fast
P1 600K
P2 1000K best-fit tends to
P3 300K 2000K work better w.r.t.
P4 200K
2300K
P3 storage utilization
P5 100K
2560K 13
0 0
OS OS
400K 400K
P1 P1
process memory
1000K 1000K
P1 600K compaction P3
P2 1000K 1300K
P3 300K 2000K
P4 1200K P3
2300K
2560K 2560K
15
16
18
0010001001 0000110110011001110111
p d
001000100111 00001101100110011101
p d
20
21
22
25
p1 p2 d
Page table
28
Segmentation is similar
to paging, except that
partitioning is based on
the user's view of
memory
User sees a program
as a collection of
segments
For example
main program,
function,
object,
global variables,
stack,
symbol table,
…
29
30
31
32
33
34
35