Showing posts with label Paging. Show all posts
Showing posts with label Paging. Show all posts

Friday, July 29, 2011

Paging

Hello friends in this post we are going to discuss on paging and how an operating system used it for memory management.

Paging is another memory management technique which widely uses virtual memory concept. When paging is used, the processor divides the linear address space into fixed-size pages (of 4KBytes, 2 MBytes, or 4 MBytes in length) that can be mapped into physical memory and/or disk storage. When a program (or task) references a logical address in memory, the processor translates the address into a linear address and then uses its paging mechanism to translate the linear address into a corresponding physical address.

Some physical memory is reserved for the operating system itself, and for its data structures. This is called wired memory, because it is not subject to paging. The rest of physical memory is managed via the paging mechanism, and is called the page pool. Whenever a virtual memory page that is not in physical memory is referenced, a page is allocated from the page pool’s free list and mapped to the required virtual memory address. Pages are returned to the free list when the memory has been unmapped or freed. Pages can be reclaimed from the free list if they are referenced again before the physical memory page has been reused.
OS performs an operation for storing and retrieving data from secondary storage devices for use in main memory. Paging is one of such memory management scheme. Data is retrieved from storage media by OS, in the same sized blocks called as pages. Paging allows the physical address space of the process to be non contiguous. The whole program had to fit into storage contiguously.

Paging is also used to deal with external fragmentation problem. This is to allow the logical address space of a process to be noncontiguous, which makes the process to be allocated physical memory.

You can also visit my other blogs:
Networking Concepts
Technomedia
Enter into world of Technology
Hina Rabbani Khar




Monday, July 18, 2011

Demand Paging

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 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.
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.