Paging

 Introduction to Paging:-

 Paging is a storage mechanism used in OS to retrieve processes from secondary storage to the main memory as pages. The primary concept behind paging is to break each process into individual pages. Thus the primary memory would also be separated into frames.

One page of the process must be saved in one of the given memory frames. These pages can be stored in various memory locations, but finding contiguous frames/holes is always the main goal. Process pages are usually only brought into the main memory when they are needed; else, they are stored in secondary storage.

The frame sizes may vary depending on the OS. Each frame must be of the same size. Since the pages present in paging are mapped onto the frames, the page size should be similar to the frame size.



Demand Paging:-

 The demand paging system is similar to the swapping paging system in that processes are mostly stored in the main memory (usually on the hard disk). As a result, demand paging is a procedure that addresses the problem above just by shifting pages on demand. Lazy swapper is another name for this ( It never swaps the page into the memory unless it is needed).

A pager is a kind of swapper that deals with the individual pages of a process.

Demand Paging is a method in which a page is only brought into main memory when the CPU requests it. At first, just those pages are loaded directly required by the operation. Pages that are never accessed are thus never loaded into physical memory.


Paging Replacement Algorithms:-

 The page Replacement Algorithm decides which page to remove, also called swap out when a new page needs to be loaded into the main memory. Page Replacement happens when a requested page is not present in the main memory and the available space is not sufficient for allocation to the requested page.

When the page that was selected for replacement was paged out, and referenced again, it has to read in from the disk, and this requires I/O completion. This process determines the quality of the page replacement algorithm: the lesser time waiting for page-ins, the better the algorithm.

A page replacement algorithm tries to select which pages should be replaced so as to minimize the total number of page misses. There are many different page replacement algorithms. These algorithms are evaluated by running them on a particular string of memory references and computing the number of page faults. The fewer page faults the better the algorithm for that situation.

Some Page Replacement Algorithms :

  • First In First Out (FIFO)
  • Least Recently Used (LRU)
  • Optimal Page Replacement