Table of contents
1.
Introduction
2.
Inverted Page Table
2.1.
Examples
3.
Advantages and Disadvantages
4.
Frequently Asked Questions
4.1.
What is demand paging?
4.2.
What is the structure of the page table?
4.3.
How many entries are there in an inverted page table?
5.
Conclusion
Last Updated: Mar 27, 2024

Inverted Page Table in Operating System

Author Sanjana Yadav
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?
Operating Systems

Introduction

Most operating systems implement a separate page table for each process, i.e., there are n page tables kept in memory for the 'n' number of processes running on a Multiprocessing/ Time-Sharing operating system.

When a process is vast in size and takes up a lot of virtual memory, the page table size grows dramatically. 

Also see, Introduction to Paging

Example: 

A process of size 4 GB with:
Page size = 512 Bytes
Size of page table entry = 8 Bytes, then
Number of pages in the process = 4 GB / 512 B = 223
PageTable Size = 223 * 23 = 226 bytes

This example shows that when numerous processes are operating in an OS simultaneously, page tables take up a significant amount of memory. 

Multilevel paging strategies are also included in operating systems, which increase the amount of space necessary for storing page tables and demand a lot of memory.

The amount of memory occupied by page tables can be a significant overhead, which is always undesirable because main memory is always a limited resource.

Various attempts are made to optimize memory and maintain a healthy balance between multiprogramming and efficient CPU use. 

 

Inverted Page Table

Another option is the Inverted Page Table structure, which consists of a one-page table entry for every main memory frame.

As a result, the number of page table entries in the Inverted Page Table is reduced to the number of frames available in physical memory. A single-page table represents all processes' paging information. 

The overhead of holding a separate page table for each process is reduced with the inverted page table. A fixed area of memory is required to store the paging information of all processes together.

Because the indexing is done with respect to the frame number rather than the logical page number, this technique is known as inverted paging.

The fields listed below are found in each page table entry. 

  • Page number - It specifies the logical address's page number range. 
  • Process Id - All of the processes under execution have their address space information stored in an inverted page table. Because two processes can have a similar set of virtual addresses, the Inverted Page Table must maintain a process Id for each process to uniquely identify its address space. This is accomplished by combining the PId and the Page Number. As a result, this Process Id serves as an address space identifier, ensuring that a virtual page for a specific process is accurately mapped to the physical frame. 
  • Control Bits - Extra paging-related information is stored in these bits. The valid bit, dirty bit, reference bits, protection, and locking information bits are among them. 
  • Chained Pointer - It's feasible that two or more processes will share a section of main memory at some point. In this situation, two or more logical pages map to the same Page Table Entry, and the details of these logical pages are mapped to the root page table via a chaining pointer. 


The working and operation of the inverted page table are shown below

The fields and other essential information necessary in paging-related mechanisms are contained in the virtual address created by the CPU and each page table entry.

Illustration Image

When a memory reference occurs, the memory-mapping unit matches the virtual address, searches the Inverted Page table for a match, and obtains the matching frame number.

If a match is discovered at the ith entry, the process's physical address is provided as the real address; a Segmentation Fault is triggered if no match is found. 

Note: The number of entries in the inverted page table is equal to the number of frames in the physical address space (PAS) 

Examples

The Inverted Page table and its variants are used in various systems, including the PowerPC, UltraSPARC, and IA-64 architectures.

This approach is also used in an RT-PC implementation of the Mach operating system.                                                                       

You can also read about the interleave memory.

Advantages and Disadvantages

  • Reduced memory space - Inverted Page Tables minimize the memory needed to store the page tables to a physical memory size limit. The physical memory's maximum number of entries might be the number of page frames. 
  • Longer lookup time - Inverted Page tables are arranged in frame number, but memory lookups are performed concerning the virtual address; thus, it takes longer to identify the correct entry. However, hash data structures are frequently used to speed up the lookup. 
  • Difficult shared memory implementation - Implementing shared memory in the page tables becomes challenging because the Inverted Page Table only maintains a single item for each frame. Chaining techniques are needed to map multiple virtual addresses to the entry supplied in the frame number sequence.

 

Must Read Evolution of Operating System

Frequently Asked Questions

What is demand paging?

The demand paging system is similar to the swapping paging system in that processes are primarily stored in the main memory (usually in the hard disk). As a result, demand paging is a procedure that addresses the problem above just by shifting pages on demand. This is also sometimes referred to as a lazy swapper ( It never swaps the page into the memory unless it is needed).

What is the structure of the page table?

The structure of a page table essentially specifies how many different ways it may be constructed. As the name implies, Paging is a memory management approach in which a significant process is broken into pages and stored in physical memory, divided into frames. The frame and page sizes are the same. The operating system uses a page table to convert the logical address of a page created by the CPU to its physical location in the main memory. 

How many entries are there in an inverted page table?

Number of entries in inverted page table = physical address space/page size.

Conclusion

  • Cheers if you reached here! In this blog, we learned about Inverted Paging in Operating Systems.
  • We have covered the need for Inverted Paging and its definition.
  • We have also seen it working with an example.
  • Further, we saw its examples.
  • We have also witnessed the Advantages and Disadvantages of Inverted Paging in OS.


On the other hand, learning never ceases, and there is always more to learn. So, keep learning and keep growing, ninjas!

With this fantastic course from CodingNinjas, you can make learning enjoyable and stress-free.

Recommended Reading:

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Live masterclass