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.

In this Paging tutorial, you will learn:

Example

For example, if the main memory size is 16 KB and Frame size is 1 KB. Here, the main memory will be divided into the collection of 16 frames of 1 KB each.

There are 4 separate processes in the system that is A1, A2, A3, and A4 of 4 KB each. Here, all the processes are divided into pages of 1 KB each so that operating system can store one page in one frame.

At the beginning of the process, all the frames remain empty so that all the pages of the processes will get stored in a contiguous way.

In this example you can see that A2 and A4 are moved to the waiting state after some time. Therefore, eight frames become empty, and so other pages can be loaded in that empty blocks. The process A5 of size 8 pages (8 KB) are waiting in the ready queue.

In this example, you can see that there are eight non-contiguous frames which is available in the memory, and paging offers the flexibility of storing the process at the different places. This allows us to load the pages of process A5 instead of A2 and A4.

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.

What is Segmentation?

Segmentation method works almost similarly to paging, only difference between the two is that segments are of variable-length whereas, in the paging method, pages are always of fixed size.

A program segment includes the program's main function, data structures, utility functions, etc. The OS maintains a segment map table for all the processes. It also includes a list of free memory blocks along with its size, segment numbers, and it's memory locations in the main memory or virtual memory.

Advantages of a Segmentation method

Here, are pros/benefits of Segmentation

  • Offer protection within the segments
  • You can achieve sharing by segments referencing multiple processes.
  • Not offers internal fragmentation
  • Segment tables use lesser memory than paging

Disadvantages of Segmentation

Here are cons/drawback of Segmentation

  • In segmentation method, processes are loaded/ removed from the main memory. Therefore, the free memory space is separated into small pieces which may create a problem of external fragmentation
  • Costly memory management algorithm

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
  • Segmentation method works almost similarly to paging, only difference between the two is that segments are of variable-length whereas, in the paging method, pages are always of fixed size.
  • You can achieve sharing by segments referencing multiple processes.
  • Segmentation is costly memory management algorithm

 

YOU MIGHT LIKE: