The CPU architecture usually determines the page size, and pages in a system used to be the same size, such as 4,096 bytes. Due to the benefits, processor designs frequently allow two or more page sizes. There are various factors to consider while determining the optimum page size.
In this article, we will look more into Finding Optimal Page Size according to the GATE Syllabus for (Computer Science Engineering) CSE. Let us read ahead to find out more about it.
How to Find the Optimal Page Size?
As we already know, larger page tables incur more overhead since we must break the table into pages and store them in the main memory.
Our primary concern must be with the execution of processes rather than with the execution of the page tables. The process is carried out with the help of a page table. The bigger the overhead, the larger would be the page Table.
Now, it is known that,
The size of the page table = total number of page entries per page table * the size of a single page entry
We will now consider an example,
If the Virtual Address Space = 2 GB = 2 X 2 ^ 30 Bytes
and Page Size = 2 KB = 2 X 2 ^ 10 Bytes
Thus, the total number of Pages present in page table = (2 X 2 ^ 30)/(2 X 2 ^ 10) = 1 M pages
Thus, there would be 1M (1 million) pages, which is quite a big number. But we can try to make the page size comparatively larger, let’s say 2 MB.
Thus, the total number of pages present in a page table = (2 X 2 ^ 20)/(2 X 2 ^ 30) = 1 K pages.
Now, in case we compare these two scenarios, we could find that the size of the page table is anti proportional to the size of the page.
We can observe that there’s always some sort of wastage in the last page in the case of paging. In case the virtual address space isn’t a multiple of the page size, there would be some of the bytes remaining. Thus here, we must assign an entire page to these many bytes. It would simply be an overhead.
Let us consider the following,
Virtual Address Space = 17 KB
Page Size = 2 KB
Thus, the total number of pages = 17 KB / 2 KB
Here, the total number of pages would be 9, even though the ninth page will only consist of 1 byte. The remaining page would be wasted.
Now, in general,
If the size of the page = p bytes
The Virtual Address Space = S bytes
Entry size = e bytes
Then, the O (overhead) = (p/2) + (S/p) X e
On average, the number of pages wasted in a virtual space would be p/2 (half of the total number of pages).
Thus, for a minimal overhead,
∂O/∂p = 0
-S/(p^2) + 0.5 = 0
And p = √ (2.S.e) bytes
Thus, in case the page size is √(2.S.e) bytes, the overhead would be minimal.
Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit Card, GATE Syllabus, GATE Previous Year Question Paper, and more.
Also Explore,
- Batch Operating System
- Binary Semaphores in Operating System
- Contiguous Memory Allocation in Operating System
- Counting Semaphores in Operating System
- Deadlock Detection and Recovery in Operating System
- Deadlock Prevention in Operating System
- Distributed Operating System
- Dynamic Partitioning in Operating System
- Fixed Partitioning in Operating System
- Functions of Operating System
- Methods for Handling Deadlock in Operating System
- Multiprogramming Operating System
- Multitasking Operating System
- Network Operating System
- Non-Contiguous Memory Allocation in Operating System
- Operating System Services
- Paging in OS
- Process in Operating System
- Process Scheduler in Operating System
- Process Scheduling in Operating System
- Process State in Operating System
- Real-Time Operating System
- Resource Allocation Graph in Operating System
- Semaphores in Operating System
- Time-Sharing Operating System
- Types of Operating System