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: 139Word Count: 1000See All articles From Author

Add Comment

Education Articles

1. Mastering Fire Safety: The Role Of A Fire Safety Instructor
Author: Qualtec

2. A Global Perspective: The Transformative Impact Of Studying Abroad
Author: Abhilash

3. Exploring Logistics And Supply Chain Management Courses In Trivandrum: Your Path To A Dynamic Career
Author: Capitalits

4. A Student’s Packing List For Germany: Essential Items For Your Adventure
Author: Uniaccess Study Abroad

5. Water Glass
Author: nehashah

6. Choir Lessons In East Bay – Tips To Choose The Best
Author: Pleasanton Academy of Music

7. Top Reasons To Choose The Best Music Studio In East Bay
Author: Pleasanton Academy of Music

8. Azuredevsecopsonlinetraining | Azuredevopstraininginhyderabad,
Author: Renuka

9. Mendix Training In Ameerpet | Mendix Online Training
Author: Teja

10. How Pune's Top Education Consultants Can Help With Scholarships
Author: Aashu

11. Introduction To Azure Databricks? Creation Of Workspace And Managing Workspace
Author: Eshwar

12. What Are Python Developer Roles And Responsibilities?
Author: Sarika

13. The Valuable Function Of Business Analytics
Author: Giri

14. Role Of A Teacher In Early Childhood Education
Author: Kookaburra

15. Debunking Common Data Science Misconceptions
Author: Gour

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