Open In App

Performance and Working of Paging

Last Updated : 23 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Paging is a memory management technique used in operating systems to divide a process's virtual memory into fixed-sized pages. The performance of paging depends on various factors, such as:

  • Page size: The larger the page size, the less the number of page tables required, which can result in faster memory access times.
    However, larger page sizes also result in internal fragmentation, where memory is wasted due to the difference between the actual size of a process and the size of a page.
  • Page replacement algorithms: The performance of paging depends on the page replacement algorithm used. Common algorithms include FIFO, LRU, and LFU. The choice of algorithm will affect the number of page faults and the time taken to access a page.
  • Page table size: The size of the page table used to map virtual addresses to physical addresses affects the speed of memory access. A larger page table results in slower memory access times.
  • Page table organization: The organization of the page table can also affect the performance of paging. A hierarchical page table, for example, can reduce the size of the page table and increase the speed of memory access.

In general, paging can improve the performance of a system by allowing processes to access more memory than is physically available and by improving the utilization of memory. However, excessive paging can result in slow performance due to a high number of page faults and the overhead associated with accessing the page table.

Performance of Paging

Evaluating the performance of paging is crucial for understanding how efficiently memory is being used in a system.

When we talk about Effective Memory Access Time (E.M.A.T), we’re measuring how long it takes to access data in memory, considering both the page table lookup and the actual memory access.

let’s assume:

  • The time to access the main memory is m.
  • The page table (which stores the mapping between logical and physical addresses) is also kept in main memory.

Now, since accessing data requires two steps:

  1. First, we have to access the page table to find the location of the required data.
  2. Then, we access the actual data in memory using the address obtained from the page table.

This means that we’re performing two memory accesses for every data access. So, the formula for Effective Memory Access Time (E.M.A.T) becomes:

E.M.A.T = 2 * m

Features of Performance of Paging

  • Translation lookaside buffer(TLB) is added to improve the performance of paging.
  • The TLB is a hardware device implemented using associative registers.
  • TLB access time will be very less compared to the main memory access time.
  • TLB contains frequently referred page numbers and corresponding frame numbers.

Working of Paging

1. Paging:

  • Paging is a memory management technique that divides the process's address space into equal-sized blocks called pages.
  • Each page size is a power of 2.
  • Main memory is also divided into fixed-sized blocks called frames, and the frame size matches the page size to optimize memory usage and avoid external fragmentation.

2. Address Translation:

The logical address (used by the process) consists of:

  • Page number (identifies which page of the process).
  • Page offset (identifies the specific byte within the page).

The physical address (used by the system) consists of:

  • Frame number (points to the location in main memory).
  • Page offset (remains the same as the logical address).

3. Page Table:

  • A page table is a data structure that keeps track of the mapping between the process's pages and the physical memory frames.
  • It helps in translating logical addresses into physical addresses during execution.

4. Frame Allocation: When a page is allocated a frame in memory, the logical address is translated into a physical address using the page table. This mapping is maintained throughout the program’s execution.

5. Memory Management During Execution:

  • If a program (e.g., 8KB in size) cannot fit completely into memory (say, only 5KB can be loaded at once), the system uses paging to manage this.
  • The OS moves idle pages to secondary memory (like disk storage) when RAM is full, freeing up space for active pages.
  • When the program needs those pages again, the OS retrieves them from secondary memory and loads them back into RAM.

6. Continuous Paging: This process of swapping pages between RAM and secondary memory continues throughout the execution of the program to ensure the system runs efficiently despite limited RAM.

Now, let's see the diagram given below of the performance of paging for a better understanding.

paging
paging

A process runs, and the OS divides it into fixed-size pages. Then the pages are mapped to the respective page frames in physical memory with the help of the page table and when a page is requested either it is a hit or it will be a miss given below:

  • Page Hit: If the page is present in memory, the execution continues.
  • Page Fault: If not present it result into a miss and the OS:
    • Finds the page’s location via the page table.
    • Loads it into a page frame.
    • Updates the page table.
    • Resumes the process.

Evaluating Expression for the performance of paging :

Consider the TLB access time is 'c'. And the TLB hit ratio is 'x' then the Evaluating Expression for the performance of paging is as follows.

Effective Memory Access Time (E.M.A.T) with TLB = x(c+m) + (1-x) (c + 2m)

Advantages of Paging

  • The main advantage of paging is it reduces external fragmentation.
  • Paging provides a way for the operating system to manage the memory used by a process, ensuring that each process has enough memory to run effectively.
  • Improved Memory Utilization: By dividing a process's virtual memory into pages, paging allows the operating system to use memory more efficiently.
  • Improved Process Isolation: By separating a process's virtual memory into pages, paging provides a degree of isolation between processes.
  • Reduced Memory Fragmentation: Paging helps to reduce memory fragmentation by allocating memory in fixed-sized pages, rather than as a continuous block.

Disadvantages of Paging

  • The main disadvantage of Paging is it suffers from Internal fragmentation because pages have a fixed size, there may be unused space within a page.
  • Overhead: Paging introduces overhead in the form of additional data structures (e.g., page tables) and disk I/O operations required to swap pages in and out of memory.
  • Page Faults: Paging can result in a large number of page faults, where the operating system needs to access the disk to retrieve a page that is not currently in memory.
  • Limited Address Space: The use of paging can limit the size of the virtual address space available to a process, as the virtual address space is divided into pages of a fixed size.

Next Article

Similar Reads