Lecture 27: Virtual Memory
Review: goals of memory management Memory allocation A new process comes into memory Memory de-allocation A process leaves memory Address translation Virtual address to physical address Process isolation One process cannot access the memory of other processes
Review: Memory management for different systems Processes are known in advance and can fit in memory Embedded systems, e.g., radios, washing machines, and microwaves Processes are unknown in advance, memory might not be large enough Swapping Virtual memory
Review: Swapping Each individual process can fit in memory But memory cannot fit all processes Memory allocation/de-allocation Bitmap Linked list Dynamic address translation Base register in CPU Process isolation Limit register in CPU
Virtual memory What if a single process is larger than memory? Not all parts of the large process are equally possible to be used Put the parts that are less used in disk The process can still run Load a part from disk to memory when needed
Paging: Key idea of virtual memory Divide a program into fixed-size small parts Called virtual pages or pages Divide the memory into fixed-size small blocks Called page frames Load some pages into page frames
An example of paging 64K Virtual Address Space 32K Physical Memory Divided into 16 pages 4K for each page 32K Physical Memory 8 pages of 4K each
Problems in paging Address translation Page fault When a page that the process is trying to use is not in memory, hardware issues page fault Load in the page into a page frame Which page frame goes to disk? This is called page replacement problem