123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Education >> View Article

Working Of Demand Paging In Operating System

Profile Picture
By Author: Abhishek Sharma
Total Articles: 7
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

Have you ever thought of how a computer provides you with all the information without crashing or running multiple of your requests without messing them up?

Well, this is done with the help of a phenomenon called paging and sometimes demand paging.

In the paging approach, the system code is divided into smaller codes that a processor can easily manage. After that, with the help of the demand paging technique, only the required page is provided to the main memory. In this way, you get the required process or program that you wish without facing any crashes.

But the main question is, how this whole process is carried out in such a small period?

To help you understand how demand paging in OS works, we have come up with this comprehensive guide.

Check out everything that you need to know about demand paging in this post!

Understanding Demand Paging in OS

Demand paging is simply a scheme to manage the memory used to manage the physical memory resources available to be used by modern operating systems.
It is a process to move the data from secondary storage to RAM when ...
... demanded. This simply means that all the data is not present in the main memory because of the limited space.

Therefore, when the CPU demands a certain page or process and RAM does not have that page, it performs swapping. It shifts a page from RAM and gets the demanded page to RAM.

Let's understand demand paging in OS with a real-life example:

For instance, you have been to a store to buy clothes. Now, the shopkeeper will check if the products you have asked for are available in the shop or not.

To check that, he will first check the maintained records. However, if it is not available in the shop, he will ask the helper to get the same from the warehouse.

In that way, he will only bring the item that you have demanded. Keep note that not everything will be available in the shop because it has very limited space.

Other than this, the customer will only visit the shop to get things rather than going to the warehouse.

In the same way, when you ask for a page from RAM, if it is not available in it, it will ask for the same from the secondary storage.

Why is demand paging required?

Now that you have understood what demand paging in the OS is, let's discuss why you need one.

The main reason behind performing demand paging is to make efficient use of the existing resources of the system.

Now that you are aware that there are multiple pages available in a system, however, keeping all of them in the main memory is not suitable.

Therefore, the only efficient method to save space in RAM is through paging and loading pages only those which are in demand.

Other than this, one of the major advantages to use demand paging is that it decreases the time required to respond to all requests made by the user and hence, increases the performance of the system.

To understand better, consider an example to run a program to calculate the cost of painting your room.

For this, you can use different codes. Consider that three pages are available which have different codes.

P1: This page will calculate the labour cost.
P2: This page will calculate the paint cost
P3: This page will calculate the overall surface area.

In case, the user wishes to calculate the labour cost only. In that case, the CPU will only get page number 1. However, if there was no concept of pages 2 and 3, the whole program would have loaded which takes more space.

Working on demand paging

When a demand for a certain page is made, the system will refer to the page table to check if the required page is available. In case the required page is available in the main memory, the program will be executed.

However, if it is not available, the page fault situation will occur.

Now, in the case of a page fault, we will have to perform a swapping of the page. For that, we will have to remove the page from the hard disk and it will be then put into the RAM or main memory of the computer.

In the demand paging technique, you will also come across valid and invalid bits that are generally present in each entry of the page table.

Therefore, when the CPU attempts to find any page in the memory, it will also check for invalid and valid bits related to the page.

Invalid bits: In case a particular bit is invalid, it simply means that the required page is either not available currently on the disk or the page is no longer valid.

Valid bits: In case a particular bit is valid, the required page is then considered valid and legal.

Steps Involved In Demand Paging

To begin with, when you make a request on any page, the page table will be consulted. In case any of the available frames are invalid, the following steps will be performed.

=> In case there is a page fault, it will generate an interruption.
When an interruption occurs, the operating system will move to the blocked state.

=> After this, the requested process will be searched in the secondary memory.

=> You need to now check if any free frame is available. In case any free frame is not available, a page replacement algorithm will be used.
It will then replace the page.

=> After replacement, the CPU is informed that the pages have been updated. It will then execute the process.

Conclusion

The paging process is very important to ensure the proper functioning of multiprogramming operating systems and other OS. It helps the operating system to manage all the processes in the limited memory space.
The demand paging process is quite important for modern operating systems to ensure that each of the required processes has proper access to the memory.

Total Views: 431Word Count: 1000See All articles From Author

Add Comment

Education Articles

1. Data Science Course With Job Assistance: Building Skills For A Career In Ai
Author: BIA

2. Gemstone Wisdom: How To Understand, Choose And Wear Traditional Astrological Stones
Author: Narendra Sharma

3. How To Crack Neet 2027: Mock Tests, Previous Year Papers And Ai Practice
Author: Sarthaks eConnect

4. Mlops Online Course And Mlops Training In Ameerpet
Author: Subahan

5. Best Ai Product Management Training | Visualpath
Author: Visualpath

6. How Can Ai Turn Sap Data Into Business Insights
Author: golla kalyan

7. D365 Finance And Operations Training | D365 Training
Author: Hari

8. Forward Deployment Engineering Course | Visualpath
Author: Vamsi Ulavapati

9. Power Bi Training With Ai | Power Bi Classes Online
Author: Visualpath

10. Cissp Certification Guide 2026: Exam, Requirements, Training, And Preparation Strategy
Author: passyourcert net

11. Build Your Career With Practical Sap Training At Avina Technologies, Hyderabad
Author: Avina Technologies

12. Asphalt Calculator: Calculate Asphalt Quantity, Weight, And Cost Easily
Author: agecalculatot

13. How To Teach Young Children Who Can Not Read Junior Bible Quiz Questions
Author: JBQ Companion

14. Singapore Student Visa 2027: Complete Guide For Indian Students
Author: Nivesa EdTech

15. Sap Cloud Platform Integration Training | Sap Cloud Platform
Author: Visualpath

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: