Performance of 2-Level Paging


A two-level paging system, sometimes known as hierarchical paging, is a way to translate virtual addresses to physical addresses in a computer system with a lot of physical memory.

The page table is split into two sections in a two-level paging scheme: a top-level page table and a bottom-level page table. Pointers to the bottom-level page tables are present in the top-level page table. A piece of the virtual address space is mapped to a component of the physical address space in each bottom-level page table.

The processor initially utilizes the page number to index into the top-level page table when a process produces a virtual address. A pointer to the bottom-level page table that holds the virtual address mapping may be found in the resultant item in the top-level page table. The CPU then accesses the bottom-level page table using the page offset to index and get the physical address.

The operating system's memory overhead and page table size are decreased by the two-level paging strategy. Lowering the time needed to search the page table, also boosts the system's speed.

Working of 2-Level Paging

To transform virtual addresses into physical addresses, a two-level page table is used to split virtual memory into fixed-size pages. A list of page table entries that lead to the second level of the page table may be found in the first level of the page table, sometimes referred to as the page directory. A list of page table entries that convert virtual addresses into physical addresses may be found on the page table's second level, also referred to as the page table.

When a program accesses memory, the processor looks in the page table's first level for the item that corresponds to the virtual address. A reference to the page table's second level may be found in this entry. The page table item matching the virtual address is then located by the processor by scanning the second level of the page table. The physical address that matches the virtual address is listed in this entry.

Performance Metrics

A variety of performance indicators may be employed to assess the effectiveness of 2-level paging. The page fault rate is one crucial measure. This counts the number of times a program tries to access a page that must be swapped in from the disc because it is not physically in memory. The system may be spending too much time switching pages in and out of memory, which might impede system performance if the page failure rate is high.

The TLB hit rate is another crucial measure. This tally represents the proportion of memory accesses that are handled by the TLB (translation lookaside buffer). To provide quicker memory access, the TLB is a cache that saves previously utilized page table entries. A high TLB hit rate may be a sign that the system is utilizing the TLB effectively and swiftly accessing memory.

Another crucial performance metric is memory overhead. This calculates how much RAM is required to hold the page tables. A high memory overhead might mean that the system is storing page tables in too much memory, which would reduce the amount of memory that is available to applications.

Formulas for Calculating Performance in 2-Level Paging

A number of indicators, including average access time, hit rate, and miss rate, may be used to assess the memory system performance of a computer. The formulae below can be used to determine some of these performance measures for a two-level paging system.

Average memory access time

AMAT= (t1+t2 ×p) + (t3+t4 ×q)

Where −

  • t1 is the time to access the first-level page table

  • t2 is the time to access a second-level page table entry

  • p is the probability of a first-level page table hit

  • t3 is the time to access the memory page

  • t4 is the time to update a page table entry

  • q is the probability of a second-level page table hit

First-level page table hit rate

p=1-q

where q is the second-level page table hit rate.

Second-level page table hit rate

q=1-(1/S)×(1-H)

where −

  • S is the number of entries in a second-level page table

  • H is the hit rate of a memory page in the second-level page table

Memory page hit rate

H=1-(1/F)^((1/B) )

where −

  • F is the number of frames in memory

  • B is the number of page table entries that can fit in a memory frame

Be aware that these calculations are approximations and do not account for all the elements that might impact a paging system's performance, including page replacement techniques, caching, and TLB caching.

Real-World Applications

The efficiency of two-level paging, commonly referred to as two-level virtual memory paging, is a crucial component of computer architecture with several practical uses. The virtual address space of a process is split into a page directory and a page table in 2-level paging. This makes it possible to manage memory resources effectively and to keep processes separate from one another.

  • Two-level paging is often used in contemporary operating systems including Windows, Linux, and macOS. The memory resources of active processes are managed by these systems via 2-level paging.

  • The operating system may make sure that each process only has access to its own memory space and cannot interfere with other processes' memory by partitioning the virtual address space of each process into distinct page directories and tables. This enhances the system's overall security and stability.

Virtual machines are another setting for 2-level paging. To distribute memory resources across several guest operating systems running on a single physical machine, virtual machines employ two-level paging.

  • The page directory and table given to each guest operating system allow for effective memory management and separate security for each guest system from the others.

  • Moreover, 2-level paging can be employed in real-time applications and embedded systems, where memory resources are frequently constrained.

  • These systems may effectively manage their available memory by employing 2-level paging, which also guarantees that crucial processes have the resources they require to function properly.

Across a broad range of computer applications, the effectiveness of 2-level paging is a key component of the efficient and safe use of memory resources.

Future Work

The performance of 2-level paging still needs to be improved significantly. Future studies should examine the effects of various page table arrangements. For instance, researchers may look at the effects of employing page tables with more than two layers or a hybrid strategy that mixes paging with other memory management strategies.

Future studies should also examine the effects of various page widths. The performance of the system can be significantly impacted by the size of the pages utilized in 2-level paging. To find the best page size for various applications, researchers might examine the effects of employing lower or bigger page sizes.

Conclusion

In summary, 2-level paging is an essential part of contemporary memory management. It offers various benefits, including less memory fragmentation and improved memory allocation management. It might also have some disadvantages, such as the extra work required to maintain tables with several pages. The page fault rate, TLB hit rate, and memory overhead are a few performance indicators that may be used to assess the performance of 2-level paging. In practical applications, 2-level paging offers a dependable and efficient method of managing memory and is frequently utilized in embedded devices and operating systems. Even though there is still much to be done to enhance 2-level paging's performance, it is still an essential part of contemporary memory management and is probably going to be utilized for many years to come.

Updated on: 19-Jul-2023

354 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements