Hardware and Control Structures
Two characteristics of paging and segmentation are the keys to this breakthrough:
-
All memory references within a process are logical addresses that are dynamically translated into physical addresses at run time.
→ A process may be swapped in or out of main memory such that it occupies different regions of main memory at different times during the course of execution
-
A process may be broken up into a number of pieces (pages or segments) and these pieces need not be contiguously located in main memory during execution
→ Combination of dynamic run-time address translation and the use of a page or segment table permits this
If these 2 characteristics are present, it is not necessary that all of the pages or segments of a process be in main memory during execution
- Operating system brings into main memory a few pieces of the program
- Resident set → the portion of a process that is actually in main memory at any time
- An interrupt is generated when an address is needed that is not in main memory
- Operating system places the process in a blocking state
- Piece of process that contains the logical address is brought into main memory
- OS issues a disk I/O Read request
- Another process is dispatched to run while the disk I/O takes place
- An interrupt is issued when disk I/O is complete, which causes the OS to place the affected process in the Ready state
Implications:
- More processes may be maintained in main memory
- Because only some of the pieces of any particular process are loaded, there is room for more processes
- This leads to more efficient utilization of the processor because it is more likely that at least one of the more numerous processes will be in a Ready state at any particular memory
- A process may be larger than all of main memory
- If the program being written is too large, the programmer must devise ways to structure the program into pieces that can be loaded separately in some sort of overlay strategy
- With virtual memory based on paging or segmentation, that job is left to the OS and the hardware
- The OS automatically loads pieces of a process into main memory as required
- Real memory → process executed in main memory, the actual RAM
- Virtual memory → memory on disk (allows for effective multiprogramming and relieves the user of tight constraints of main memory)
Locality and Virtual Memory
Thrashing
- A state in which the system spends most of its time swapping process pieces rather than executing instructions
- To avoid this, the OS tries to guess, based on recent history, which pieces are least likely to be used in the near future
Operating System Software