1. Home
Operating System

OS Tutorial: Learn Operating Systems Basics

Learn Operating System fundamentals: concepts, processes, memory management, and more. Start your journey to mastering OS with our comprehensive tutorial.

  • 47
  • 7 Hours
right-top-arrow

Tutorial Playlist

47 Lessons
23

Paging in Operating System

Updated on 19/07/2024472 Views

Paging is a method techies like us use to get access to data faster in all types of operating systems. When I require a page, it's available in the main memory because the OS copies a set number of pages from the storage device into the main memory. 

It is a management strategy that helps unlink the physical address space which further aids in paged memory allocation with the contiguous physical memory.

Let’s explore more about Paging in OS.

Paging in Operating System: What It Is

Paging serves as a memory management technique within operating systems, designed to remove the necessity for continuous allocation of physical memory. It involves fetching processes, organized into pages, from secondary storage into the main memory. The core concept of paging in OS is to break each process into individual pages.

In paging, the physical memory is partitioned into fixed-size blocks termed page frames, matching the size of the pages utilized by the process. Concurrently, the logical address space of the process is divided into fixed-size blocks known as pages, aligning with the dimensions of the page frames. Upon a memory request from a process, the operating system assigns one or more page frames to the process and establishes mappings between the logical pages of the process and the physical page frames.

To learn more about operating systems and the world of software as a whole, consider joining professional development bootcamps.

Types of Paging in Os

As a computer geek with an interest in the intricate workings of operating systems, I find the concept of paging particularly exciting. Paging in memory management is an important feature that plays an active role in resource utilization and optimizing system performance. In this section, I will walk you through the types of paging in OS, offering insights from my very own experience.

1. Single-level Paging 

  • It is one of the easiest forms of paging
  • Every entry in the page table has the frame number correlated with a page.
  • The fixed-size frames also get divided by the physical memory.
  • The page table is required to plan logical addresses to physical addresses.
  • This scheme lacks the limitation that the page table itself can become very large for large address spaces.

 2. Multi-level Paging

  • Multi-level paging in OS is an add-on of single-level paging.
  • It focuses on reducing the size of the page table by initiating multiple levels of page tables.
  • The logical address is divided into multiple parts in this scheme with each part used as an index into a different level of the page table ranking.
  • This helps in reducing the memory overhead of storing the entire page table in memory.
  • Multi-level paging allows for efficient memory management of large address spaces.

3. Inverted Paging

  • Inverted paging is a paging technique used in a few operating systems to control the scalability issues of old paging schemes.
  • Despite having a page table for each process, there is a single page table for the entire system.
  • Each entry in the page table consists of the page number, process ID, and frame number.
  • When a page reference takes place, the operating system searches the page table for the corresponding entry.
  • Inverted paging is appropriate for systems with a large number of processes but can be less efficient due to the need for table searching.

4. Segmented Paging

  • Segmented paging in OS is a fusion of segmentation techniques and paging.
  • It divides the logical address space into segments, each with its own size and protection attributes.
  • Each segment is further divided into pages, and a page table is maintained for each segment.
  • It offers more flexibility in paging in memory management by allowing different segments to grow dynamically.
  • It suffers from visible fragmentation issues.

Important Features of Paging in Memory Management

Paging in OS plays an important role in running memory in personal computers. It allows us to efficiently manage resources and run larger programs than could fit into physical memory alone. Let’s look at some crucial features of paging in memory management. 

Virtual Memory 

One important feature of paging is its capacity to create virtual memory. Your computer may use disk space as an extension of physical memory. It's like having extra space to store data when physical memory runs low. 

Paging helps manage the mapping between virtual addresses used by programs and physical addresses in RAM or secondary storage, which makes your computer more adaptable and able to run complex tasks.

Page Size

Page size refers to the fixed-size blocks into which memory is divided. These blocks are used for both virtual and physical memory. Common page sizes include 4 KB, 8 KB, and 16 KB. The choice of page size can impact system performance and memory efficiency. 

Smaller page sizes reduce internal fragmentation but might require larger page tables, while larger page sizes can reduce overhead but may lead to more wasted memory. Finding the right balance is crucial for optimal performance.

Page Table

The page table is an important data structure used by the operating system to manage the plotting between physical addresses and virtual addresses. Each entry in the page table corresponds to a page in virtual memory and contains the corresponding frame number in physical memory. 

There are many ways to implement paging in OS  with tables, each with its own advantages. For example, if you check inverted page tables or series page tables provide different trade-offs regarding access time and memory overhead.

Page Fault Handling

Minor page faults during paging in OS happen when a program tries to access a page that's not currently in physical memory. The operating system handles these faults by swapping out less frequently used pages from memory to disk and bringing the requested page into memory. 

Efficient page fault handling is crucial for maintaining an active system. Methods like pre-fetching and demand paging can help lower page faults and revamp overall efficiency.

TLB (Translation Lookaside Buffer)

TLB is a stored memory that stocks freshly accessed virtual-to-physical address translations. It helps speed up address translation by offering faster access to frequently used page table entries. 

TLB misses happen when a requested translation is unable to be found in the TLB, which leads to additional overhead in accessing the page table. Fixing TLB management is crucial for lowering memory access latency and improving system performance. 

Advantages and Disadvantages of Paging 

Let’s discuss the advantages and disadvantages of paging in memory management in the following sections: 

Advantages

  • Efficient memory management: Paging helps in effective memory management simply by dividing physical memory into fixed-size blocks known as frames and logical memory into pages of the same size. This allows the operating system to allocate and deallocate memory strongly, making it ideal for available resources.
  • Virtual memory support: One of the notable advantages of paging is its support for virtual memory. It allows the execution of programs bigger than the available physical memory by using disk space as an extension. Paging makes it possible to plot between virtual and physical memory addresses, allowing for easy execution of large programs.
  • Flexibility in memory allocation: It offers flexibility in paged memory allocation by allowing processes to use non-contiguous memory segments. Unlike contiguous memory allocation schemes, which need continuous blocks of memory, paging shows the breakup form of memory allocation, lowering the similarities of memory wastage and fragmentation.
  • Simplified memory protection: Paging eases the memory protection method by offering a mechanism to control access permissions at the page level. By setting appropriate permissions for individual pages, the operating system can stop unauthorized access to memory regions, improving system stability and security.

Disadvantages

  • Overhead: Paging introduces overhead regarding process time and memory space. Every process needs its page table to plot virtual addresses to physical addresses, which consumes significant memory resources, especially for big-sized address spaces. Moreover, page table lookups suffer processing overhead, which affects system performance.
  • Fragmentation: Paging leads to internal division, where memory is wasted due to incomplete page allocation. When a process's memory requirements do not align with the page size, the remaining space within a page may be wasted, contributing to reduced memory efficiency and fragmentation.
  • Page faults: This happens when a process tries to access a page that is not currently in physical memory, it needs the operating system to fetch the page from secondary storage. While paging allows efficient use of physical memory, excessive page faults result in low performance, particularly if the disk access time is high.
  • TLB misses: The Translation Lookaside Buffer (TLB) is a storage memory that stores recently accessed page table entries to accelerate address translation. TLB misses happens when a requested translation is unable to be found in the TLB, and results in additional memory access latency and reduced performance.

Conclusion

One key aspect I realized about paging is how important of a role it plays in improving system performance and resource utilization. Paging in OS is a fundamental aspect of memory management. It has revolutionized how computers use resources and handle memory allocation. 

In today’s fast-paced era where technological advancement is a daily phenomenon, there is a hike in demand for expertise in the concept of paging in OS. 

If this subject intrigued you, why not transform it into a full-blown career option? Platforms such as upGrad offer various online courses according to your needs. They are designed to give you in-depth knowledge in your field and will help you elevate your career.Whether you are already in an IT background or willing to get into IT, their courses will surely give you the boost you need to flourish in this professional stream. 

Frequently Asked Questions (FAQs)

  1. What is an example of a paging system?

A good paging in OS with example could be the traditional alphanumeric pager used in various industries such as healthcare, emergency services, and hospitality. These pagers receive short messages or numerical codes. It helps users to be notified of important information or tasks.

  1. What are the benefits of paging?

The paging system offers several facilities:

  • Improved security
  • Easy memory management
  • Cost-effectiveness
  • Increased memory utilization
  • Support for virtual memory
  • Isolation and scalability in memory management
  1. Which is better paging or segmentation?

In the concept of paging in OS, it depends on the requirements of the system. Paging eases memory management and supports virtual memory which helps in internal fragmentation. Segmentation provides flexibility in paged memory allocation that leads to external fragmentation and complexity.

  1. Why is paging used in the OS?

Paging is used for memory management, supports virtual memory, and elevates system performance by dividing physical memory into fixed-size blocks(pages). It allows processes to access memory flexibly.

  1. What is demand paging in the OS?

Demand paging is a memory management method in operating systems where pages are loaded into memory only when needed.

  1. What are the disadvantages of paging?

There are a few disadvantages of paging, such as:

  • Internal fragmentation
  • Overhead from managing page tables
  • Increased access time due to additional address translation
  • Potential for thrashing
  • Complexity in implementation and management
  • Occurrence of page faults
  1. Is there fragmentation in paging?

Yes, there can be internal fragmentation in the concept of paging in OS, where some space within allocated pages remains unused.

  1. What is the difference between paging and frames?

Paging divides both physical and virtual memory into fixed-size blocks (pages), while frames are the fixed-size blocks of physical memory used for memory allocation and mapping in the context of paging.

Kechit Goyal

Kechit Goyal

Team Player and a Leader with a demonstrated history of working in startups. Strong engineering professional with a Bachelor of Technology (BTech…Read More

Get Free Career Counselling
form image
+91
*
By clicking, I accept theT&Cand
Privacy Policy
image
Join 10M+ Learners & Transform Your Career
Learn on a personalised AI-powered platform that offers best-in-class content, live sessions & mentorship from leading industry experts.
right-top-arrowleft-top-arrow

upGrad Learner Support

Talk to our experts. We’re available 24/7.

text

Indian Nationals

1800 210 2020

text

Foreign Nationals

+918045604032

Disclaimer

upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enr...