Demand Paging in Operating System:

Definition and Explanation:

Virtual memory can be implemented by a technique called demanding paging. It is a technique in which a Page is brought into memory when-it is actually needed.
A typical life cycle of a process is as follows;
1. When a process is initiated, the operating system must at least load one page in real memory. It is the page containing the execution part of the process.
2. Execution of the process commences and proceeds through subsequent instructions beyond the starting point.
3. This execution continues as long as memory references generated by this page are also within the same page. The virtual address created may reference a page that is not in real memory. This is called a page fault. It generates an interrupt that asks for the referenced page to be loaded. This is called demanding page.
4. The operating system will try to load the referenced page into a free real memory frame. When this is achieved the execution can continue.
5. Finally when the process terminates, the operating system releases all the pages belonging to the process. The pages become available to other processes.
The below diagram shows virtual to real allocation for three processes A, B and C. Note that only some portions of the processes are loaded in real memory because the whole processes cannot fit in the memory:

Figure/Diagram:

Now consider what happens if there is no free frame where to load a referenced page? For example, in the diagram above, the execution is at page A5. If a new page A6 from process A is referenced then it must be loaded in real memory. But the memory is already full with pages.
In general, the operating system accommodates the new page by removing a currently loaded page that is not in use. This is called page replacement. It is important to remove a page that will not be accessed in a short time. It will reduce the number of page faults in the system.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Blog Archive

Powered by Blogger.

- Copyright © 2013 Taqi Shah Blogspot -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -