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 address, 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 tutorial, you will learn

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.

KEY DIFFERENCES:

  • A page is of the fixed block size whereas a segment is of variable size.
  • In Paging, the hardware decides the page size while the segment size is specified by the user.
  • The paging technique is faster for memory access but segmentation is slower than paging method.
  • In paging, the user just provides a single integer as the address while in segmentation, there is the availability of many independent address spaces
  • Page table stores the page data while Segmentation table stores the segmentation data.

Difference between Paging and Segmentation

Here, are differences between Paging and Segmentation method:

Paging Segmentation
A page is of the fixed block size. A segment is of variable size.
It may lead to internal fragmentation. It may lead to external fragmentation.
In Paging, the hardware decides the page size. The segment size is specified by the user.
A process address space is broken into fixed-sized blocks, which is called pages. A process address space Is broken in differing sized blocks called sections.
The paging technique is faster for memory access. Segmentation is slower than paging method.
Page table stores the page data Segmentation table stores the segmentation data.
Paging does not facilitate any sharing of procedures. Segmentation allows for the sharing of procedures.
Paging fails to distinguish and secure procedures and data separately. Segmentation can be able to separate secure procedures and data.
Paging address space is one dimensional In segmentation, there is the availability of many independent address spaces
In paging, the user just provides a single integer as the address, that is divided by the hardware into a page number and offset. In the segmentation method, the user specifies the address in two quantities 1)segment number 2)offset.

Advantages of Paging

Here, are pros/benefits of using Paging method

  • On the programmer level, paging is a transparent function and does not require intervention.
  • Frames do not have to be contiguous.
  • Easy to use memory management algorithm
  • Swapping is easy between equal-sized pages and page frames.

Advantage of Segmentation

Here, are pros/benefits of Segmentation:

  • Simple to relocate segments than the entire address space.
  • The absence of internal fragmentation as external fragmentation has to be done.
  • The segment table is of lesser size compared with the page table in paging.
  • The average size of the segment is larger to the actual size of the page
  • Offer protection within the segment
  • Not offers internal fragmentation
  • Segment tables use lesser memory than paging
  • As it offers the small segment table, memory reference is simple, which lends itself to sharing data among processes.

Disadvantages of Paging

Here, are cons/drawbacks of Paging:

  • Paging causes internal fragmentation on older systems.
  • Longer memory lookup times compared to segmentation
  • It may cause internal fragmentation
  • Complex memory management algorithm
  • Page tables consume additional memory.
  • Multi-level paging may lead to memory reference overhead.

Disadvantages of Segmentation

Here, are cons/drawbacks of Segmentation:

  • Un-equal size of segments is not good in the case of swapping.
  • Porting Linux to different architectures is difficult to process because it offers very limited support for segmentation.
  • It demands programmer intervention.
  • It is hard to allocate contagious memory to partition as it is of its variable size.
  • This is costly memory management algorithm.

 

YOU MIGHT LIKE: