HOME

virtual memory



Virtual memory is a technique that allows a execution of a process that may not be completely in memory. The main visible advantage of this scheme is that programs may be larger than the physical memory.

Virtual memory is the seperation of user logical memory from physical memory . this seperation allows an extreamely large virtual memory to be provided for programmers when only a smaller physical memory is available. virtual memory makes the task of programing much easier, because the programer no longer needs to worry abotu the amount of physical memory available ,or about or what code can be placed in overlays , but can concentrate instead on the problem to be programed.on system which supports virtual mem.,overlays have virtually disappeared.

Virtual memory is commonly implemented by demand paging .it can also be implemented in a segmentation system. several systems provide a paged segmentation scheme, where segments are broken into pages thus the user view is segmentation, but the operating systems can implement this view with demand paging . demand segmentation can also be used to provide virtual memory . burroughs computer system have used demand segmentation the IBM OS/2 operating system also uses demand segmentation . however, segment replacement algo rithms are more complex then are page replacement algorithms because the segments have variable sizes.

Benefits of virtual memory




A program would no longer be constrained by the amount of physical memory i.e. available, user would be able to write programs for an extreamely large virtual address space,simplifing the programing task. Because each user program could take less physical memory , more programs could be run at the same time , with a corres ponding increase inCPU utilization and through put, but with no increase in response time or turn around time . Less I/O would be needed to load or swap each user program into memory , so each user program would run faster.


Demand paging



A demand - paging system is similar to a paging system with swapping . processes reside on secondary memory (which is usually a disk) when we want to execute a process, we swap it into memory.

Rather than swapping the entire process, we swap it into memory. rather than swapping the entire process into memory.,however, we use a lazy swapper. a lazy swapper never swaps apage into memory unless that page will be neede . since we are now viewing a process as asequence of pages, rather than one large contiguos add.space, the use of the term swap is tecnically incorrect. a swapper manipulates entire processes, whereas a pageris concerned with the indivisual pages of a process. we shall thus use the term pager, rather than swapper, in connection with demand paging .

When a process is to be swapped in ,the pager guesses which pages will be used before the process is swapped out again. instead of swapping in awhole process, the pager brings only those necessary pages into memory. Thus it avoids reading into memory pages that will not be used anyway, decreasing the swap time and the amount of physical memory needed.

With this scheme , we need some form of hardware support to distiguish between those pages that are in memory and those pages that are on the disk. the valid - invalid bit schemecan be used for this purpose.

FIFO Algorithm




The simplest page - replacement algorithm is a FIFO algorithm. A FIFO replace ment algorithm associates with each page the time when that page was brought into memory . when a page must be replaced, the oldest page is chosen.

Notice that it is not strictly neccessary to record the time when a page is brought in. We can create a FIFO queue to hold all pages in memory we replace the page at the head of the queue. When a page is broght into memory, we insert it at the tail of the queue.

Optimal Algorithm




One result of the discovery of belady's anomaly was the seach for an optimal page replacement algorithm. An optimal page replacement algorithm. an optimal page replacement algorithm has the lowest page fault rate of all algorithms. an optimal algorithm will never suffer from belady's anomaly. An optimal page replacement algorithm eists, and has been called OPT or MIN. it is simply

Replace the page that will not be used for the longest period of time. Use of this page - replacement algorithm guaratees the lowest possible page - fault rate for a fixed no. of frames.

Global Vs Local Allocation




Another important factor in the way frames are allocated to the various processes is the page replacement , with multiple processes competing for frames , we can classify page replacement algorithms into two broad categories global replacement and local replacement. global replacement allows a process to select a replacement frame from the set of all frames even if that frame has been allocated to some another process; one process can take a frame from another. Local relacement requires that each process select from its own set of frames.