Inverted Page Table in Operating System
Last Updated :
13 Sep, 2023
Most Operating Systems implement a separate page table for each process, i.e. for the 'n' number of processes running on a Multiprocessing/ Timesharing Operating System, there is an 'n' number of page tables stored in the memory. Sometimes when a process is very large and it occupies virtual memory then with the size of the process, its page table size also increases substantially.
Example: A process of size 2 GB with:
Page size = 512 Bytes
Size of page table entry = 4 Bytes, then
Number of pages in the process = 2 GB / 512 B = 222
Page Table Size = 222 * 22 = 224 bytes
Through this example, it can be concluded that for multiple processes running simultaneously in an OS, a considerable part of memory is occupied by page tables only. Operating Systems also incorporate multilevel paging schemes which further increase the space required for storing the page tables and a large amount of memory is invested in storing them. The amount of memory occupied by the page tables can turn out to be a huge overhead and is always unacceptable as main memory is always a scarce resource. Various efforts are made to utilize the memory efficiently and to maintain a good balance in the level of multiprogramming and efficient CPU utilization.
What is an Inverted Page Table?
In an operating system that uses virtual memory, an Inverted Page Table (IPT) is a data structure used to map physical memory pages to virtual memory pages. Unlike a traditional Page Table, which is a per-process data structure, an IPT is a system-wide data structure that contains an entry for each physical page in memory.
An alternate approach is to use the Inverted Page Table structure that consists of a one-page table entry for every frame of the main memory. So the number of page table entries in the Inverted Page Table reduces to the number of frames in physical memory and a single page table is used to represent the paging information of all the processes.
Through the inverted page table, the overhead of storing an individual page table for every process gets eliminated and only a fixed portion of memory is required to store the paging information of all the processes together. This technique is called inverted paging as the indexing is done concerning the frame number instead of the logical page number.
Components of Inverted Page Table
Each entry in the page table contains the following fields.
- Page number: It specifies the page number range of the logical address.
- Process id: An inverted page table contains the address space information of all the processes in execution. Since two different processes can have a similar set of virtual addresses, it becomes necessary in the Inverted Page Table to store a process Id of each process to identify its address space uniquely. This is done by using the combination of PID and Page Number. So this Process Id acts as an address space identifier and ensures that a virtual page for a particular process is mapped correctly to the corresponding physical frame.
- Control bits: These bits are used to store extra paging-related information. These include the valid bit, dirty bit, reference bits, protection, and locking information bits.
- Chained pointer: It may be possible sometimes that two or more processes share a part of the main memory. In this case, two or more logical pages map to the same Page Table Entry then a chaining pointer is used to map the details of these logical pages to the root page table.
Working of Inverted Page Table
The operation of an inverted page table is shown below.
Inverted Page Table
The virtual address generated by the CPU contains the fields and each page table entry contains the other relevant information required in paging related mechanism. When a memory reference takes place, this virtual address is matched by the Memory Management Unit(MMU), the Inverted Page table is searched and the corresponding frame number is obtained. If the match is found at the ith entry then the physical address of the process is sent as the real address otherwise if no match is found then Segmentation Fault is generated. Note: Number of Entries in Inverted page table = Number of frames in Physical Address Space(PAS).
Examples: The Inverted Page table and its variations are implemented in various systems like PowerPC, UltraSPARC, and the IA-64 architecture. An implementation of the Mach operating system on the RT-PC also uses this technique.
Advantages of Inverted Page Table
The Main advantages of the inverted page table are as follow:
- Reduced Memory Space: Inverted Page Tables typically reduce the amount of memory required to store the page tables to a size bound of physical memory. The maximum number of entries could be the number of page frames in the physical memory.
- Longer Lookup Time: Inverted Page tables are sorted in order of frame number but the memory look-up takes place concerning the virtual address, so, it usually takes a longer time to find the appropriate entry often these page tables are implemented using hash data structures for a faster lookup.
- Difficult Shared Memory Implementation: As the Inverted Page Table stores a single entry for each frame, it becomes difficult to implement the shared memory in the page tables. Chaining techniques are used to map more than one virtual address to the entry specified in the order of frame number.
- Optimal and Less Complex: it is better than a simple paging process and has less complexity.
- Simplified Page Swapping: When a process needs to be swapped out of memory, the IPT can be used to quickly identify all the physical pages that are associated with the process. This can simplify the process of swapping pages and reduce the overall overhead of memory management.
- Improved Cache Performance: Because the IPT is smaller than a Page Table, it can be more easily stored in the CPU cache, which can improve the performance of memory access operations.
Each entry in the IPT contains the virtual address(es) that map to that physical page, as well as other information such as the process ID of the process that owns the virtual address(es), the access permissions for the page, and other page attributes. This information is used by the operating system to manage the allocation and deallocation of physical memory pages, as well as to ensure that processes are accessing memory only in a safe and controlled manner.
However, there are also some potential disadvantages to using an IPT, such as increased overhead for lookups and the potential for contention between processes for physical memory pages. As with any memory management technique, the choice of whether to use an IPT or a Page Table depends on the specific requirements and constraints of the operating system and hardware platform being used.
Conclusion
At the end, we now know that Inverted Page Table is an important concept in Operating Systems. Systems which have big address spaces provides a better solution to the tracking and management of memory pages problem. It reduces memory usage and seen times by indexing pages according to their actual memory locations rather than their virtual addresses. It is very crucial for system developers to understand the Inverted Page Table because it is a key component of memory allocation and efficiency, which helps to maintain the general stability and responsiveness of operating systems.
Similar Reads
Difference between User Level thread and Kernel Level thread
User-level threads are threads that are managed entirely by the user-level thread library, without any direct intervention from the operating system's kernel, whereas, Kernel-level threads are threads that are managed directly by the operating system's kernel. In this article, we will see the overvi
5 min read
Introduction of Process Synchronization
Process Synchronization is used in a computer system to ensure that multiple processes or threads can run concurrently without interfering with each other.The main objective of process synchronization is to ensure that multiple processes access shared resources without interfering with each other an
10 min read
Critical Section in Synchronization
A critical section is a segment of a program where shared resources, such as memory, files, or ports, are accessed by multiple processes or threads. To prevent issues like data inconsistency and race conditions, synchronization techniques ensure that only one process or thread accesses the critical
8 min read
Inter Process Communication (IPC)
Processes need to communicate with each other in many situations. Inter-Process Communication or IPC is a mechanism that allows processes to communicate. It helps processes synchronize their activities, share information, and avoid conflicts while accessing shared resources.Types of Process Let us f
5 min read
Semaphores in Process Synchronization
Semaphores are a tool used in operating systems to help manage how different processes (or programs) share resources, like memory or data, without causing conflicts. A semaphore is a special kind of synchronization data that can be used only through specific synchronization primitives. Semaphores ar
15+ min read
Mutex vs Semaphore
In the Operating System, Mutex and Semaphores are kernel resources that provide synchronization services (also known as synchronization primitives). Synchronization is required when multiple processes are executing concurrently, to avoid conflicts between processes using shared resources. In this ar
8 min read
Deadlock, Starvation, and Livelock
Deadlock, starvation, and livelock are problems that can occur in computer systems when multiple processes compete for resources. Deadlock happens when processes get stuck waiting for each other indefinitely, so none can proceed. Starvation occurs when a process is repeatedly denied access to resour
7 min read
Introduction of Deadlock in Operating System
A deadlock is a situation where a set of processes is blocked because each process is holding a resource and waiting for another resource acquired by some other process. In this article, we will discuss deadlock, its necessary conditions, etc. in detail.Deadlock is a situation in computing where two
11 min read
Resource Allocation Graph (RAG) in Operating System
A Resource Allocation Graph (RAG) is a visual way to understand how resources are assigned in an operating system. Instead of using only tables to show which resources are allocated, requested, or available, the RAG uses nodes and edges to clearly illustrate relationships between processes and their
7 min read
Banker's Algorithm in Operating System
Banker's Algorithm is a resource allocation and deadlock avoidance algorithm used in operating systems. It ensures that a system remains in a safe state by carefully allocating resources to processes while avoiding unsafe states that could lead to deadlocks.The Banker's Algorithm is a smart way for
8 min read