0% found this document useful (0 votes)
19 views9 pages

Paging in Operating System (OS) : Real-Life Analogy: Anshuman Singh

Uploaded by

Yogyta Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views9 pages

Paging in Operating System (OS) : Real-Life Analogy: Anshuman Singh

Uploaded by

Yogyta Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Paging in Operating System (OS): Real-life

analogy
Anshuman Singh
Senior Execut ive - Cont ent
Updated on May 14, 2024 15:43 IST
Do you want to learn paging in operating system with real life analogy? Then you
have landed on the right article.This article also explains the working of paging
technique.

Operating systems have come a long way since the days of MS-DOS. With the
advent of powerful CPUs and more memory available, systems have become
smarter and more capable. However, all that power can come at a cost – slower
system responses. To avoid this, modern operating systems employ paging memory
management techniques. This technique allows the operating system to “page” data
from memory into and out of physical blocks on the hard drive. In this blog, we will be
talking about Paging in the Operating System and will check how it works.
Before understanding, I recommend you understand Memory management . This
topic is very important from the interview and exam point of view. I myself was asked
questions about this concept in an interview.

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
Must Check: History of Operating Systems

Table of contents
What is Paging
How does Paging Work
Address translation in paging
Advantages of Paging

Disadvantages of Paging
When to Use Paging

Conclusion
Let‘s understand the real-life analogy first:
Let’s assume you have a cake which you want to store in the refrigerator. There will
be two situations in this case.

When you have enough space: You have enough space in the
ref rigerator and will store the cake by just placing it. This means you
were having contiguous space available in the ref rigerator.

When you don’t have enough space: In this situation, you have to
cut the pieces of cake and put them in the ref rigerator wherever
space is available. This available space is in a non-contiguous way.
Paging is based on this concept.

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
What is Paging?

Non-contiguous memory management technique for retrieving processes from


the secondary storage into the main memory.

Paging is a memory management technique for retrieving processes from secondary


memory storage units as pages and stored in the main memory’s frame.

When a program needs to access data, it sends a request to access a process to


the operating system, which stores the process in the main memory from the
secondary memory. Each process is divided into small fixed-sized chunks called
pages; similarly, the main memory will be divided into equal-fixed-sized pieces called
f rames. The process pages are stored at a different location in the main memory.
The thing to note here is that the size of the page and frame will be the same.

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
Like in the above fig, every page in secondary memory is 2 Kb, and in the same way,
every frame in main memory is also 2 Kb.

The problem is that physical memory is finite. When all of the spaces in physical
memory are filled with requests, the operating system has to start swapping the
processes which are not in use to make room for new ones. This process is called
swapping.

Working of Demand Paging in Operat ing Syst em


This article explain a very impo rtant to pic o f o perating system-Demand paging
with real-life analo gy

CPU Scheduling Algorit hm: Operat ing Syst em


Scheduling o f pro cesses is very impo rtant thing in an o perating system. CPU
Scheduling Algo rithm is an essential part o f any o perating system. Vario us
algo rithms can be used, each with advantages...re ad m o re

Process Scheduling: Operat ing Syst em


Have yo u ever wo ndered ho w yo ur co mputer juggles multiple tasks
simultaneo usly? To kno w that, yo u must read this blo g o n pro cess scheduling

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
in the o perating system! This article includes...re ad m o re

How does Paging Work?

This process is quite simple. Your computer has a finite amount of memory, which is
used to store programs and data currently being used. When that memory is
complete and you try to open another program or save a document, your computer
has to get creative.

It can’t just delete old files or programs to free up space because that would mean
deleting data or programs you may need later. So instead, it looks for unused
memory in other parts of the computer. When it finds some, it copies the necessary
data and deletes the program or file from memory.

This process is known as paging in operating systems.

Also read: What is Operating Systems (OS) – Types, Functions, and


Examples
Also read: Operating system interview questions

Address translation in paging

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
We have two types of addresses.

1. Logical address: An address generated by the CPU is commonly referred to


as a logical address. A set of logical addresses generated by a program is a
logical address space.

2. Physical address: An address seen by the memory unit—that is, the one
loaded into the memory address register—is commonly referred to as a physical
address. A set of physical addresses corresponding to these logical addresses is
physical address space.

Let me understand this paging concept.


Firstly we should know that paging follows non-contiguous memory allocation. The
pages are stored(from secondary memory ) in the main memory at different
locations but will be the same size as the page.

Whenever a request to find a page comes, the CPU tries to find that page on main
memory because the access time of main memory is less compared to secondary
memory as main memory is smaller than secondary memory. So, if the CPU wants to
find the page, the CPU generates a logical address. The main memory has a physical
address, so the CPU wants to communicate with the main memory, so the CPU
needs to convert the logical to physical. So, we need something that can give us a
physical address corresponding to the logical address generated by the CPU. That is
done by page table, so what is a page table? The data structure stored in the
main memory stores the mapping between logical address and physical address. A
logical address will then be mapped to an actual physical address which indicates the
frame it’s in, and offset represents the location where the instruction is within the
frame.

Here we have a logical address in which the first part represents page number and
the second part represents instruction offset.

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
Suppose here p=2 and page offset=8. This means the CPU wants to access page 2
of the main memory and the eighth instruction of that page. But remember, this
address generated was for secondary memory, but the CPU must pick this page
from the main memory. So we need a physical address to access the main memory.
So CPU will check the page table and get the physical address corresponding to that
logical address.

NOTE: Different page tables will be there for different processes.

Advantages of Paging
Conserve memory by only keeping the active pages in memory. This
is especially helpf ul in large-scale systems where memory is scarce.
Enables the operating system to manage more processes by allowing
each process to have its dedicated memory space. This maximizes
ef f iciency and perf ormance by allowing the operating system to
schedule and run each process without conf licts.

Allows f or greater f lexibility and scalability regarding the size and


complexity of the systems that can be created.
Parts of the program are allowed to store at dif f erent locations in the
main memory.
It solves the problem of external f ragmentation.
Swapping becomes very easy due to equal-sized pages and f rames.

Disadvantages of Paging

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
It can be very inef f icient. When a process needs more memory, the
operating system must f ind a block of unused memory and copy it to
the process.
This process can take a long time and, in some cases, can even
crash the system.

Paging can cause internal f ragmentation, which makes the system


run more slowly.
The page table is there, which takes some memory space.
Have to maintain a page table f or each process.

Memory access time increases as the page table needs to be


accessed.

When to Use Paging


You have too many processes running and not enough physical
memory to store them all.
When you have a large process that can be split into multiple pages.
When you want to load a process into physical memory without
loading the entire process.

Conclusion
Paging is a technique used in most modern operating systems to improve
performance. When an application needs more memory than is currently available,
the operating system will page it out to disk. This allows the application to continue
running without interruption, and the memory can be reclaimed when needed. This
article covered Paging in the operating system with a real-life analogy. If this article
helped you in any way. Then please share with your friends.

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.
FAQs

What is operating system paging?

What is demand paging?

What is a page f ault?

Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 15-May-20 24.

You might also like