Open In App

Hashed Page Tables in Operating System

There are several common techniques for structuring page tables like Hierarchical Paging, Hashed Page Tables, and Inverted Page Tables. In this article, we will discuss the Hashed Page Table.

Hashed Page Tables are a type of data structure used by operating systems to efficiently manage memory mappings between virtual and physical memory addresses. 



In Hashed Page Tables, the virtual page number in the virtual address is hashed into the hash table. They are used to handle address spaces higher than 32 bits. Each entry in the hash table has a linked list of elements hashing to the same location (to avoid collisions – as we can get the same value of a hash function for different page numbers). The hash value is the virtual page number. The Virtual Page Number is all the bits not part of the page offset.

For each element in the hash table, there are three fields



Hashed Page Table

Hashed Page Table

The virtual page number is compared with field 1 in the first element of the linked list. If it matches, the corresponding page frame (field 2) is used to form the desired physical address. Otherwise, subsequent entries in the linked list are checked until the virtual page number matches. To make this algorithm suitable for 64-bit address spaces also, clustered page tables are used. Clustered Page Tables are similar to hashed page tables except that each entry in the hash table refers to many pages rather than one single page (as in a hashed page table). Hence, a single entry of a clustered page table can store the mappings for multiple physical page frames. Clustered page tables are specifically helpful for sparse address spaces, where memory references are scattered throughout the address space (non-contiguous).

Characteristics of Hashed Page Table

Clustered Page Tables

Clustered Page Tables and Hashed Page Tables are somehow similar to each other. But the main difference between these two tables is that Hashed Page Table refers to a single page whereas Cluster Page Table refers to mappings to multiple physical page frames in a single entry.

Clustered page Table is mostly used in sparse address spaces where non-contiguous address spaces are used for memory references.

FAQs on Hashed Page Table

1. Can you tell the complexity of searching a virtual address in a Hashed Page Table?

Answer:

The complexity of searching a virtual address in a Hashed Page Table is considered to be O(1) in the assumption that a good hash function and a distributed hash table.

2. Which structuring of the page table is the most memory efficient?

Answer:

Hashed Page Table is more memory efficient than any other page table structuring because it only allocates the portions that are used in the virtual address space which ultimately saves memory space.

Article Tags :