Advertisements
Virtual memory
Why preferred:
- To run larger program exceeding physical memory size
- Main Memory space for CPU is not sufficient to run large program
- Physical main memory is kept small in order to reduce cost though logical memory space is large
If no virtual Memory??
Program Folding (Overlay) : large program split into memory parts
- Before exe – load each part in memory
- After exe – store in hard disk
In virtual memory,
- User Program > Physical Main Memory
- OS stores entire program on hard disk (where hard disk > memory)
- At given time only some portions of program are brought into main memory from hard disk.
Swapping
-
At given time only some portions of program are brought into main memory from hard disk
-
Portion not needed is moved back to hard disk & stored
- For large program do swapping continuously.
Page Fault ( Virtual Memory interrupt)
-
CPU fetch instruction & data from main memory
-
If data is not present when required, hardware raises special interrupt – virtual memory interrupt/ page fault
Page fault/ virtual memory interrupt
-
In response, OS loads the required content from hard disk to main memory
-
Page fault is similar to interrupt but can occur within instruction cycle
- To support virtual memory, program does not address physical memory
Address translations:
-
When referring to operand/instruction, it gives only logical address & virtual memory hardware translates it to equivalent physical memory during execution
Advantages of virtual Memory:
-
Program size is not limited by physical memory size
-
Main memory allocation done automatically not by user
- Manual folding/ overlay is eliminated to run large program
Physical & Logical Address
-
Physical Address – actual location in main memory
-
Logical Address – memory specified by CPU.
- Physical & logical address may or may not be same
- Logical Address = segment /module/page number of program +
- Offset or word number in relation to the beginning