120 likes | 198 Vues
VIRTUAL MEMORY. Kautalya Mishra. Memory Hierarchy. Before Virtual Memory ? .
E N D
VIRTUAL MEMORY Kautalya Mishra
Before Virtual Memory ? • Programmers when confronted with the problem of having programs that were too big to fit in to the available memory came up with a solution of splitting the program in to pieces called ‘Overlays’. • Overlay 0 would start running first followed by the next overlay. The overlays were kept on the disk and swapped in and out of the memory by the operating system dynamically. • Although the work of swapping Overlays in and out was done by the system, the LABORIOUS work of splitting the program in to Overlays had to be done by the programmer.
Virtual Memory • The basic idea of Virtual Memory is to keep only those parts of the program currently in use in the memory and the rest on the disk drive. • For example: a 16M program can run on a 4M machine by carefully choosing which 4M to keep in memory at each instant, with pieces of the program being swapped between disk and memory as needed. • It can work in a Multiprogramming system, with bits and pieces of many programs brought to the memory at once by the Operating System. While a program is waiting for part of itself to be brought in, it is waiting for I/O and cannot run, so the CPU can be given to another process, the same way as for any other multiprogramming system.
Page Faults • When a page being referred to by the virtual address is not loaded as a page frame in to the memory, a page fault is occurred which causes the CPU to trap the Operating System. • The Operating System removes a page frame from the memory and loads the new page in to the freed location at the same time making appropriate changes to the page table. • There are a number of page replacement algorithms available such as The Optimal Page Replacement Algo, The Not Recently Used Page Replacement Algo, FIFO etc.
Problems faced with Virtual Memory implementation: • Possibly large page table • Thrashing Solution: • Use multilevel page tables. • Use TLB (Translation Lookaside Buffer) or sometimes called ‘Associative Memory’. • Page fault rates can be reduced by using a ‘Working Set Model’ approach or a ‘Prepaging’ approach. • Increase RAM!
Advances Made • Some advanced systems give programmers some control over the memory map so that they can used it in a non-traditional way. It allows for the possibility of sharing the same memory space between two or more processes. • Distributed Shared Memory – The idea here is to allow multiple processes over a network to share a set of pages, possibly, but not necessarily, as a single shared linear address space
References • Operating Systems – Design and Management Andrew S. Tanenbaum and Albert S. Woodhull • http://computer.howstuffworks.com/virtual-memory.htm • http://en.wikipedia.org/wiki/Virtual_memory