Paging In OS with Examples
Paging is a non-contiguous technique where one process can reside at different main memory locations. So, spanning is totally possible. In this post, we will see all about paging with examples.
Need of Paging
The main disadvantage of Contiguous Dynamic Partitioning was External fragmentation. Although Compaction may remove External fragmentation, it makes the system inefficient.
In paging, external fragmentation was totally removed without Compaction.
Explain with Example
P1 requires 3 MB of space to load in the main memory. We have two holes of 2MB and 1MB, respectively, available at different locations in the main memory. And still, Process 1 can load successfully. It is because of non-contiguous memory allocation.
Concept of Paging
In which processes are organized in equal size blocks called pages, and the main memory is organized in equal-sized blocks called frames.
Pages in secondary memory and main memory frames are the same size as the CPU and do not generate absolute addresses. But it generates the logical address.
However, the actual data required for the CPU is present in the main memory. A physical address is required to access actual data in the main memory. For this purpose, the system uses the MMU. MMU further uses the Page table. Every process has its own page table.
Entries of page table of each process = total no of pages of that process
Paging is a technique in which the main memory is organized in blocks of equal size. These blocks are also known as pages. In this technique, the address of occupied pages of physical memory is stored in a table known as a page table.
Through Paging, OS can get the physical memory location without specifying the lengthy memory address in the instruction. In this technique, the virtual address is used to map the physical address of the data. The length of the virtual address is specified in the instruction and is smaller than the physical address of the data. It consists of two different numbers; the first is the page’s address, known as a virtual page in the page table. The second number is the offset value of the actual data on the page. Let’s explain with a diagram.
Let’s Explain with an example.