Tuesday, December 29, 2009

Concept of Paging in Operating System

Concept of paging in Operating System comes in the second year of BCA in the Gujarat University syllabus. J.G. College this was asked in the assignment. It may be of interest for others too.


Page : A fixed – size section of a user’s job that corresponds to page frame in the memory.

Paging

In computer operating systems that have their main memory divided into pages, paging (sometimes called swapping) is a transfer of pages between main memory and an auxiliary store, such as hard disk drive.

[1] Paging is an important part of virtual memory implementation in most contemporary general-purpose operating systems, allowing them to use disk storage for data that does not fit into physical RAM. Paging is usually implemented as a task built into the kernel of the operating system

Overview

The main functions of paging are performed when a program tries to access pages that do not currently reside in RAM. This situation is known as a page fault. The Operating System must then take control and handle the page fault, in a manner invisible to the program. Therefore, the operating system must:

           Determine the location of the data in auxiliary storage.

          Obtain an empty page frame in RAM to use as a container for the data.

          Load the requested data into the available page frame.

          Return control to the program, transparently retrying the instruction that caused the page fault.

         The need to reference memory at a particular address arises from two main sources:

          Processor trying to load and execute a program's instructions itself.

          Data being accessed by a program's instruction.

In step 2, when a page has to be loaded and all existing pages in RAM are currently in use, one of the existing pages must be swapped with the requested new page. The paging system must determine the page to swap by choosing one that is least likely to be needed within a short time. There are various page replacement algorithms that try to answer such issue.

Most operating systems use the least recently used (LRU) page replacement algorithm. The theory behind LRU is that the least recently used page is the most likely one not to be needed shortly; when a new page is needed, the least recently used page is discarded. This algorithm is most often correct but not always: e.g. a sequential process moves forward through memory and never again accesses the most recently used page.

If a page chosen to be swapped has been modified since loading (if page is dirty), it has to be written to auxiliary storage, otherwise it is simply discarded.

In addition to swapping in pages because they are necessary, in reaction to a page fault, there are several strategies for guessing what pages might be needed, and speculatively pre-loading them.

Other Posts :

Demand Paging

MIS Case Study of Databases behind MySpace

Paging Terminology

Handling Multinational Market on Web

No comments:

Post a Comment