Professional Documents
Culture Documents
Virtual Memory
Physical memory
Case 1: My program is larger than physical memory. Now what? Consideration: Will the user program need the entire physical memory all at once?
U S E R P R O G R A M
Physical memory
Case 1: My program is larger than physical memory. Now what? Fact: The user program will not need the entire physical memory all at once. Solution: overlays.
OVERLAY #1
Physical memory
Fact: The user program will not need the entire physical memory all at once. Problem: the burden is all on the programmer (loading, unloading, partitioning,etc).
Temporal Locality
1) When a memory item is referenced once, its likely to be referenced again in the near future. 2) When I access a memory location, it is likely that I will access also other locations in the vicinity of the first.
Spatial Locality
Case 2: Several programs are running concurrently. XWindow A window manager (twm, fvwm, sawfish, etc) A command shell (csh, bash, tcsh, etc) xemacs xspim
Physical memory
Case 2: Several programs are running concurrently. XWindow A window manager (twm, fvwm, sawfish, etc) A command shell (csh, bash, tcsh, etc) xemacs xspim
Physical memory
Case 2: Several programs are running concurrently. XWindow A window manager (twm, fvwm, sawfish, etc) A command shell (csh, bash, tcsh, etc) xemacs xspim
Physical memory
Temporal Locality
1) When a memory item is referenced once, its likely to be referenced again in the near future. 2) When I access a memory location, it is likely that I will access also other locations in the vicinity of the first.
Spatial Locality
10
11
Disk space is cheap, but disk access is not! Side comment: Disk access cost has three components: the time to move the disk head to the right cylinder, the time to reach the sector in the cylinder and transfer time.
12
page i
DISK
13
A program may use a large number N of pages, even if (N*page size) is greater than the physical memory. The pages that a program uses need not be contiguous nor in order in physical memory. The programmer doesnt need to explicitly move pages to and from disk. The programmer sees the address space as if it were in a memory much larger than the physical memory. Question: What do we need to create this illusion for the programmer?
Physical memory
xemacs 3
14
15
Virtual memory
Points to notice: 1) Virtual memory defines a virtual address space. xemacs 0 xemacs 1 xemacs 2 xemacs 3 2) Virtual address space is made of pages of the same size as the physical address space. 3) The pages in virtual address space are nicely contiguous and ordered.
16
Example: Page size = 4KB = 2^12 Bytes Physical memory size = 2^18 pages = 2^30 Bytes = 1 GB Virtual memory size = 2^32 Bytes = 4 GB Question: What about this mapping from a larger to a smaller space?
17
Data
18
Important Considerations
Cache miss Page Fault: how do the penalties compare?
Pages should be large to amortize access time, but not too large. Why?) What about writing? Should we think write through or write back? Should we use a fully associative or a direct mapping scheme? Why? Should we leave page fault handling to software or should we make it a hardware task?
19
Virtual address
31 30 29 28 27 15 14 13 12 11 10 9 8 Virtual page number 3 2 1 0 Page offset 12 Physical page number
20
Valid
Page table
(each program has its own)
Page table
18 If 0 then page is not present in memory 29 28 27 15 14 13 12 11 10 9 8 Physical page number Physical address 3 2 1 0 Page offset
20
Virtual address
31 30 29 28 27 15 14 13 12 11 10 9 8 Virtual page number 3 2 1 0 Page offset 12 Physical page number
20
Valid
Page table
(each program has its own)
Page table
18 If 0 then page is not present in memory 29 28 27 15 14 13 12 11 10 9 8 Physical page number Physical address 3 2 1 0 Page offset
21
22
Disk storage
23