Structure of Page Table in Operating Systems
Structure of Page Table in Operating Systems
The data structure that is used by the virtual memory system in the
operating system of a computer in order to store the mapping between
physical and logical addresses is commonly known as Page Table.
As we had already told you that the logical address that is generated by the
CPU is translated into the physical address with the help of the page table.
The above diagram shows the paging model of Physical and logical memory.
Some of the common techniques that are used for structuring the Page table
are as follows:
1. Hierarchical Paging
2. Hashed Page Tables
3. Inverted Page Tables
Hierarchical Paging
There might be a case where the page table is too big to fit in a
contiguous space, so we may have a hierarchy with several levels.
In this type of Paging the logical address space is broke up into
Multiple page tables.
Consider a system having 32-bit logical address space and a page size of 1
KB and it is further divided into:
As we page the Page table, the page number is further divided into :
Below given figure below shows the Address Translation scheme for a two-
level page table
For a system with 64-bit logical address space, a two-level paging scheme is
not appropriate. Let us suppose that the page size, in this case, is 4KB.If in
this case, we will use the two-page level scheme then the addresses will look
like this:
Thus in order to avoid such a large table, there is a solution and that is to
divide the outer page table, and then it will result in a Three-level page
table:
This approach is used to handle address spaces that are larger than 32 bits.
In this virtual page, the number is hashed into a page table.
Given below figure shows the address translation scheme of the Hashed
Page Table:
The Virtual Page numbers are compared in this chain searching for a match;
if the match is found then the corresponding physical frame is extracted.
These are similar to hashed tables but here each entry refers to
several pages (that is 16) rather than 1.
Mainly used for sparse address spaces where memory references are
non-contiguous and scattered
Inverted Page Tables
The Inverted Page table basically combines A page table and A frame table
into a single data structure.
There is one entry for each virtual page number and a real page of
memory
And the entry mainly consists of the virtual address of the page stored
in that real memory location along with the information about the
process that owns the page.
Given below figure shows the address translation scheme of the Inverted
Page Table:
In this, we need to keep the track of process id of each entry, because many
processes may have the same logical addresses.
Also, many entries can map into the same index in the page table after going
through the hash function. Thus, chaining is used in order to handle this.