Paging in Operating System

Paging in operating system is a memory management technique that allows the system to allot non-contiguous physical address space to a process. The concept the paging resolves the problem of external fragmentation that occurs due to the continuous allocation of physical address space to processes.

Because of external fragmentation, though enough memory is available to allocate to a process but it is not in a contiguous manner. Thus, the concept of paging allows the system to allocate non-contiguous memory space to the processes.  Let’s discuss the concept of paging in detail.

Paging in Operating System

  1. What is Paging?
  2. Use of Paging
  3. How Does Paging Works?
  4. Advantages of Paging
  5. Disadvantages of Paging

What is Paging?

Paging is a memory management technique that helps in accomplishing the concept of virtual memory. Paging eliminates the need for continuous memory space by dividing the long process into pages. Further, the operating system divides the main memory into frames. The size of frames is equal to the size of pages.

Now whenever we have to execute the process, one page of the process is placed in one frame of the memory. The required pages of the process can be placed at frames present at the different memory locations of the main memory.

Although, at first the operating system tries to find the contiguous memory location so that contiguous frames can be allotted to the process. But if the contiguous frames are not available then pages are placed at the frames present at the different memory locations.

Also, only those pages of the processes are brought to the main memory that is required for the smooth execution of the processes, instead of placing all the pages of the process at once in the main memory. This helps the operating system in creating a multiprogramming environment.

Use of Paging in Operating System

Paging is useful when the system has to execute several programs simultaneously. And does not have enough main memory to store them.

Paging is useful when the system is unable to allocate contiguous space to the process in the main memory.

How Does Paging Works?

Paging divides the main memory into fixed-size blocks that we refer to as frames. And the program is divided into blocks of the same size as frames and we refer to them as pages.

When the system has to execute a process, it loads the pages of the program into available frames of main memory. Now to start the execution of a process CPU generates a logical address. The logical address includes page number (p) and page offset (d).

The system uses the page number as an index to trace the page table which has the base address of each page in the main memory i.e., frame (f). The base address (f) is then combined with the page offset (d) to compute the page’s physical address in the block of the main memory.

The image below shows the working of the paging in the operating system.

Paging in Virtual Memory in Operating System

It is the hardware that decides the size of the page and frame. The page size is usually computed using the power of 2. This size varies from 512 bytes to 16 MB.

Advantages of Paging

  1. Paging enables the system to allocate non-contiguous memory space to the process.
  2. As pages and frames are of equal size swapping between them becomes very easy.
  3. Paging supports the concept of virtual memory.
  4. Paging is helpful when we have limited main memory.
  5. With the concept of paging, we do not require external fragmentation.

Disadvantages of Paging

  1. Paging leads to internal fragmentation.
  2. The system has to maintain a page table that helps in translating the logical address provided by the CPU into the physical address where the page is stored. But the page tables consume additional space in the system.
  3. To access the pages from the frames (main memory) the system has to first access the page table which ultimately increases the memory access time.
  4. For each process, the system needs to maintain a separate page table.

The concept of paging is close from an operating system point of view. As it is difficult for the users or programmers to view their programs as blocks of fixed-size frames. So, there is another concept that supports the virtual memory technique i.e., Segmentation.

In segmentation, the system divides a program into segments on the basis of its functional components. Like a segment that has the main () function, and another segment that has stack memory requirements of the program.

Leave a Reply

Your email address will not be published. Required fields are marked *