Page Table Entries in Page Table
Last Updated :
03 Aug, 2023
A Page Table is a data structure used by the operating system to keep track of the mapping between virtual addresses used by a process and the corresponding physical addresses in the system's memory.
A Page Table Entry (PTE) is an entry in the Page Table that stores information about a particular page of memory. Each PTE contains information such as the physical address of the page in memory, whether the page is present in memory or not, whether it is writable or not, and other access permissions.
The size and format of a PTE can vary depending on the architecture of the system and the operating system used. In general, a PTE contains enough information to allow the operating system to manage memory efficiently and protect the system from malicious or accidental access to memory.
Page Table EntryThe number of Page Table Entries in a Page Table depends on the size of the virtual address space used by a process and the size of the memory pages used by the system. For example, if the virtual address space of a process is 32 bits, and the system uses 4 KB pages, then the Page Table will have 2^20 (1 million) entries, with each entry being 4 bytes in size.
In modern systems with large virtual address spaces, such as 64-bit systems, the Page Table can become very large, leading to performance issues. To address this, some systems use hierarchical page tables, where the Page Table is divided into smaller tables, each pointing to a larger table. This allows for more efficient memory management and faster access to Page Table Entries.
Information Stored in Page Table Entry
- Frame Number - It gives the frame number in which the current page you are looking for is present. The number of bits required depends on the number of frames. Frame bit is also known as address translation bit.
Number of bits for frame = Size of physical memory / Frame Size
- Present/Absent Bit: Present or absent bit says whether a particular page you are looking for is present or absent. In case it is not present, that is called Page Fault. It is set to 0 if the corresponding page is not in memory. Used to control page faults by the operating system to support virtual memory. Sometimes this bit is also known as a valid/invalid bit.
- Protection Bit: The protection bit says what kind of protection you want on that page. So, these bits are for the protection of the page frame (read, write, etc).
- Referenced Bit: Referenced bit will say whether this page has been referred to in the last clock cycle or not. It is set to 1 by hardware when the page is accessed.
- Caching Enabled/Disabled: Sometimes we need fresh data. Let us say the user is typing some information from the keyboard and your program should run according to the input given by the user. In that case, the information will come into the main memory. Therefore main memory contains the latest information which is typed by the user. Now if you try to put that page in the cache, that cache will show the old information. So whenever freshness is required, we don't want to go for caching or many levels of memory. The information present in the closest level to the CPU and the information present in the closest level to the user might be different. So we want the information to be consistent, which means whatever information the user has given, the CPU should be able to see it as first as possible. That is the reason we want to disable caching. So, this bit enables or disables caching of the page.
- Modified Bit: Modified bit says whether the page has been modified or not. Modified means sometimes you might try to write something onto the page. If a page is modified, then whenever you should replace that page with some other page, then the modified information should be kept on the hard disk or it has to be written back or it has to be saved back. It is set to 1 by hardware on the write-access to a page which is used to avoid writing when swapped out. Sometimes this modified bit is also called the Dirty bit.
Advantages of Using a Page Table in a Virtual Memory System
- Efficient Use of Memory: Virtual memory allows the operating system to allocate only the necessary amount of physical memory needed by a process, which reduces memory waste and increases overall system performance.
- Protection: Page Tables allow the operating system to control access to memory and protect sensitive data from unauthorized access. Each PTE can be configured with access permissions, such as read-only or no access, to prevent accidental or malicious modification of memory.
- Flexibility: Virtual memory allows multiple processes to share the same physical memory space, which increases system flexibility and allows for better resource utilization.
- Address Translation: Page Tables provide the mechanism for translating virtual addresses used by a process into physical addresses in memory, which allows for efficient use of memory and simplifies memory management.
- Hierarchical Design: Some systems use hierarchical page tables, which provide a more efficient method for managing large virtual address spaces. Hierarchical page tables divide the Page Table into smaller tables, each pointing to a larger table, which allows for faster access to Page Table Entries and reduces the overall size of the Page Table.
Questions For Practice
1. Consider a machine with 64 MB of physical memory and a 32-bit virtual address space. If the page size is 4KB, what is the approximate size of the page table? (GATE CS 2001)
(A) 16 MB
(B) 8MB
(C) 2MB
(D) 24 MB
Solution: Correct Answer is (C).
For a detailed solution, refer to GATE CS 2001, Question 46.
2. In a virtual memory system, the size of the virtual address is 32-bit, the size of the physical address is 30-bit, the page size is 4 Kbyte, and the size of each page table entry is 32-bit. The main memory is byte addressable. Which one of the following is the maximum number of bits that can be used for storing protection and other information in each page table entry? (GATE CS 2004)
(A) 2
(B) 10
(C) 12
(D) 14
Solution: Correct Answer is (D).
For a detailed Solution, refer to GATE CS 2004, Question 66.
3. Consider a system with byte-addressable memory, 32-bit logical addresses, 4-kilobyte page sizes, and page table entries of 4 bytes each. The size of the page table in the system in megabytes is ___________. (GATE CS 2015)
(A) 2
(B) 4
(C) 8
(D) 16
Solution: Correct Answer is (B).
For a detailed solution, refer to GATE CS 2015 (Set 1), Question 65
Similar Reads
Introduction of System Call
A system call is a programmatic way in which a computer program requests a service from the kernel of the operating system on which it is executed. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it requests the operating system'
11 min read
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