Paging in Operating System(OS)


What is Paging?

 Paging is a storage mechanism that allows OS to retrieve processes from the secondary storage into the main memory in the form of pages. In the Paging method, the main memory is divided into small fixed-size blocks of physical memory, which is called frames. The size of a frame should be kept the same as that of a page to have maximum utilization of the main memory and to avoid external fragmentation. Paging is used for faster access to data, and it is a logical concept. The physical address space of a process to be non – contiguous.

 

  • Logical Address or Virtual Address (represented in bits): An address generated by the CPU
  • Logical Address Space or Virtual Address Space( represented in words or bytes): The set of all logical addresses generated by a program
  • Physical Address (represented in bits): An address actually available on memory unit
  • Physical Address Space (represented in words or bytes): The set of all physical addresses corresponding to the logical addresses.

Example:

  • If Logical Address = 31 bit, then Logical Address Space = 231 words = 2 G words (1 G = 230)
  • If Logical Address Space = 128 M words = 27 * 220 words, then Logical Address = log2 227 = 27 bits
  • If Physical Address = 22 bit, then Physical Address Space = 222 words = 4 M words (1 M = 220)
  • If Physical Address Space = 16 M words = 24 * 220 words, then Physical Address = log2 224 = 24 bits

Address generated by CPU is divided into:

  • Page number(p): Number of bits required to represent the pages in Logical Address Space or Page number
  • Page offset(d): Number of bits required to represent particular word in a page or page size of Logical Address Space or word number of a page or page offset.

Physical Address is divided into:

  • Frame number(f): Number of bits required to represent the frame of Physical Address Space or Frame number.
  • Frame offset(d): Number of bits required to represent particular word in a frame or frame size of Physical Address Space or word number of a frame or frame offset.

What is Paging Protection?

The paging process should be protected by using the concept of insertion of an additional bit called Valid/Invalid bit. Paging Memory protection in paging is achieved by associating protection bits with each page. These bits are associated with each page table entry and specify protection on the corresponding page.

 

Advantages of Paging:

Here, are advantages of using Paging method:
  • Easy to use memory management algorithm
  • No need for external Fragmentation
  • Swapping is easy between equal-sized pages and page frames.

Disadvantages of Paging

Here, are drawback/ cons of Paging:

  • May cause Internal fragmentation
  • Complex memory management algorithm
  • Page tables consume additonal memory.
  • Multi-level paging may lead to memory reference overhead.

Summary:

  • Paging is a storage mechanism that allows OS to retrieve processes from the secondary storage into the main memory in the form of pages.
  • The paging process should be protected by using the concept of insertion of an additional bit called Valid/Invalid bit.
  • The biggest advantage of paging is that it is easy to use memory management algorithm
  • Paging may cause Internal fragmentation

Comments