Paging in Operating System

FREE Online Courses: Click for Success, Learn for Free - Start Now!

A memory management scheme and storage mechanism that eliminates the need for contiguous physical memory allocation is known as paging. The physical address space of a process is non-contiguous. Paging allows an OS to transfer processes from the secondary storage to the main memory. These processes are transformed in the form of pages.

This is a logical concept that ensures faster data access. Some terms involved in paging are:

  • Logical Address (Virtual Address): It is represented in bits and is the address generated by the CPU
  • Logical Address Space (Virtual Address Space): It is represented in words/bytes and is the set of all the logical addresses that a program generates.
  • Physical Address: It is represented in bits and is an address that is actually present on the memory unit.
  • Physical Address Space: It is represented in words/bytes and is a set of physical addresses that correspond to logical addresses.

Paging Technique in OS

Paging technique is the mapping done from virtual address to physical address by the MMU (a hardware device). The Physical Address Space is divided into multiple fixed-size blocks. These blocks are called frames. Whereas, Logical address Space is divided into fixed-size pages. Here the size of a page is equal to the size of a frame which allows maximum utilization of the main memory and avoids external fragmentation.

The address generated by a CPU is divided into:

1. Page number(p): This is the number of bits that represent the pages in Logical Address Space or Page number.

2. Page offset(d): This is the number of bits that represent a particular word in a page or the page size of Logical Address Space or page offset.

We can divide Physical Address into:

1. Frame number(f): This is the number of bits that represent the frame of Physical Address Space or Frame number.

2. Frame offset(d): This is the number of bits that represent a particular word in a frame or frame size of Physical Address Space or frame offset.

Hardware implementation of Page Table

Dedicated registers help in the hardware implementation of a page table. But this is satisfactory until the page table is small. For larger page tables we use a translation Look-aside buffer (TLB). It is a small and fast look up hardware cache.

Features of TLB

  • It is associative and has high speed memory.
  • Each of its entries is divided into two parts, namely, tag and value.
  • It compares an item with all the tags simultaneously and if the item is found, then the corresponding value is returned.

What is Paging Protection?

Insertion of an additional bit – a Valid/Invalid bit, can help protect a paging process. Whereas, we can achieve Paging Memory protection by associating protection bits with each page.

Advantages of Paging in OS

Following are the advantages of Paging in OS:

  • The memory management algorithm is easy to use.
  • External Fragmentation is not required.
  • Swapping between equal-sized pages and page frames becomes easier.

Disadvantages of Paging in OS

Following are the disadvantages of paging in Operating System:

  • Internal fragmentation.
  • Additional memory consumption by Page tables.
  • Memory reference overhead due to multi-level paging.

Segmentation in OS

Segmentation is similar to paging, except that the length of segments is variable and pages have a fixed size. The segment of a program comprises the program’s main function, data structures, utility functions, etc.

All this information about processes is maintained in the form of a segment map table by the OS. This table also includes a list of free memory blocks, their sizes, segment numbers, and their memory locations in the main memory or virtual memory.

Advantages of Segmentation

Following are the advantages of segmentation:

  • Provides protection within segments.
  • Segments referencing multiple processes can help achieve sharing.
  • No internal fragmentation
  • As compared to paging, segment tables use lesser memory.

Disadvantages of Segmentation

Following are the disadvantages of segmentation:

  • Separation of free memory space into small pieces can cause external fragmentation.
  • It is costly.

Summary

A memory management scheme and storage mechanism that eliminates the need for contiguous physical memory allocation is known as paging. Paging technique is the mapping done from virtual address to physical address by the MMU (a hardware device). Segmentation is similar to paging, except that the length of segments is variable and pages have a fixed size.

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

follow dataflair on YouTube

Leave a Reply

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