22-06-2013, 12:19 PM
Memory Management:Overlays and Virtual Memory
Memory Management.ppt (Size: 375.5 KB / Downloads: 50)
How Does a Program Start Running?
OS (loader) copies a program from permanent storage into RAM on PCs and workstations, the “operating system” copies the program (bits) from disk.
CPU’s Program Counter is then set to the starting address of the program and the program begins execution.
ARM Linker Supports Overlays
Overlay manager loads an overlay segment when it is not in RAM
Supports Static and Dynamic Overlays
Static overlays
One root segment
2 or more memory partitions (1 for the root partition which is always in RAM)
Within each partition, any number of overlay segments
Only 1 overlay segment can be in a partition at a given time
Application writer specifies what is in each partition and segment
Dynamic Overlay
Include re-location information with each overlay segment
Have overlay manager allocate memory for an overlay segment when it is first loaded
Load and unload overlay segments by explicit calls to overlay manager
Each overlay segment is given its own name linker links each as if it were in its own partition
Solution: Virtual Memory
What is virtual memory?
Technique that allows execution of a program that may not completely reside in memory (RAM)
Allows the computer to “fake”' a program into believing that its memory space is larger than physical RAM
Why is VM important?
Cheap no longer have to buy lots of RAM
Removes burden of memory resource management from the programmer
Other benefits ...
How Does VM Work ?
Two memory “spaces”
Virtual memory space what the program “sees”
Physical memory space what the program runs in (size of RAM)
On program startup
OS copies program into RAM
If there is not enough RAM, OS stops copying program and starts it running with only a portion of the program loaded in RAM
When the program touches a part of the program not in physical memory (RAM), OS catches the memory abort (called a page fault) and copies that part of the program from disk into RAM
In order to copy some of the program from disk to RAM, OS must evict parts of the program already in RAM
OS copies the evicted parts of the program back to disk