Paging in Operating System
What is Paging in OS?
Paging is a memory management technique used by computer operating systems to manage the memory of a computer system. It is a virtual memory management technique that allows the physical memory of a computer system to be divided into small fixed-sized blocks or pages. Each page is typically 4KB in size, although this may vary depending on the operating system.
Why do we need Paging?
The primary purpose of paging is to enable the operating system to manage memory efficiently. The operating system can allocate memory to processes in smaller, manageable chunks rather than allocating the entire memory space at once. This allows the operating system to more efficiently use the available memory, as well as provide the illusion of a larger amount of available memory to each process than what is physically present.
Examples
Suppose a process requires 20KB of memory to run. The computer system only has 16KB of available physical memory. In this scenario, the operating system can divide the process into 5 pages, each of size 4KB. Only the pages required for the process to run are loaded into the physical memory at any given time. When the process requires more memory than what is currently available in physical memory, the operating system can swap out some of the pages to the hard disk and bring in new pages as needed. This process of swapping pages in and out of physical memory is known as page swapping.
Another example could be the case where two different processes are running simultaneously on a computer system. Each process may require a different amount of memory to run. Paging allows the operating system to allocate memory to each process in smaller chunks, which enables efficient utilization of the available physical memory.
Paging also enables the operating system to provide memory protection to processes. Each page is assigned a protection level, which prevents one process from accessing the memory of another process. This helps to prevent system crashes and other security issues that can arise when processes access each other's memory.
Summary
In summary, paging is an essential memory management technique used by operating systems to manage memory efficiently, provide the illusion of a larger amount of available memory to each process, and enable memory protection between processes.
Related articles
{ Understanding Demand Paging and Segmentation in Operating Systems }
Subscribe to my newsletter
Read articles from Harsh Mange directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Harsh Mange
Harsh Mange
This is Harsh Mange, working as a Software Engineer - Backend at Argoid. I love building apps. Working on contributing to open-source projects and the dev community.