CREATE OWN LIBRARY

Calculation of Optimal Page Size

 

Page size is defined by the hardware system. It determines the number of bits required to represent the byte number on a page. Page size also determines      

     

A. Memory wastage due to internal fragmentation

B. Size of the page table for a process.

C. Page fault rates when a fixed amount of memory is allocated to a process.

 

Page table is inversely proportional to page size

 

Let's take an example

Process size = Virtual Address Space (VAS) = 16GB  and page size = 4KB

 

So, 4 million is very larger of the number of pages and in that page table will be very high.

 

Now, if page size = 16MB = 224 then

 

So, it is clear that if the page size is increased then the page table size is decreased. 

 

Internal fragmentation due to page size 

Sometimes process size is an exact multiple of pages, then there will be no internal fragmentation and no memory wastage:

 

Example:

Process size = Virtual Address Space (VAS) = 20KB and page size = 2KB

Number of pages = VAS / Page size = 20 / 2 = 10K

 

So, there are 10 pages that contain the whole process no wastage of memory because of no chance of internal fragmentation.

 

But this does not happen every time. Generally in paging half of the pages get wastage because the last page only contains a small part of the process. Because may internal fragmentation. 

 

Example:

Process size = Virtual Address Space (VAS) = 19KB and page size = 2KB

 

Number of pages = VAS / Page size = 19 / 2 = 10K because the value of number of pages rounded upward.

 

So, here 10 pages are required and the last page contains only 1 byte so, the remaining page will be wastage. And this causes internal fragmentation.

 

Thus internal fragmentation varies directly with the page size, while page table size varies inversely with it.

 

Total overhead of how much memory will be wastage in general:

Let, Virtual Address Space (VAS) = S byte,

        Page size = p byte  and 

        Page Table Entry (PTE) size = e byte.

 

Now, half of the pages among process are wastage in memory = p2 (the process due to internal fragmentation is)

 

 

Now, the total overhead due to the page table and the internal fragmentation loss is given by the sum of these two terms:

 

 

The first term (page table size) is large when the page size is small. The second term (internal fragmentation) is large when the page size is large.

 

The optimum page size must lie somewhere in between. By taking the first derivative with respect to p and equating it to zero, we get the equation: 

 

 

Hence, p = 2Se is a suitable page size where memory wastage will be reduced.

 

For (Virtual Address Space) S= 1MB and e = 8 bytes per page table entry, the optimum page size is 4 KB.

 

Commercially available computers have used page sizes ranging from 512 bytes to 64 KB. A typical value used to be 1 KB, but nowadays 4 KB is more common.

 

Note: This formula is very important in the examination.