0
0
Operating Systemsknowledge~30 mins

Demand paging in Operating Systems - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Demand Paging
📖 Scenario: You are learning how an operating system manages memory using demand paging. Demand paging loads pages into memory only when they are needed, which helps save memory space.
🎯 Goal: Build a simple step-by-step explanation of demand paging using a dictionary to represent pages and their status, then simulate checking and loading pages on demand.
📋 What You'll Learn
Create a dictionary called pages with page numbers as keys and their status ('not loaded') as values
Create a variable called page_to_load and set it to the page number 3
Write a loop using for page, status in pages.items() to check if page_to_load is in the dictionary and update its status to 'loaded' if it is 'not loaded'
Add a final statement that sets a variable page_status to the status of page_to_load in the pages dictionary
💡 Why This Matters
🌍 Real World
Operating systems use demand paging to efficiently manage memory by loading only the pages a program needs at a given time.
💼 Career
Understanding demand paging is important for roles in system administration, software development, and IT support where memory management concepts are essential.
Progress0 / 4 steps
1
Create the pages dictionary
Create a dictionary called pages with these exact entries: 1: 'not loaded', 2: 'not loaded', 3: 'not loaded', 4: 'not loaded', 5: 'not loaded'.
Operating Systems
Need a hint?

Use curly braces to create a dictionary with keys 1 to 5 and all values set to 'not loaded'.

2
Set the page to load
Create a variable called page_to_load and set it to the integer 3.
Operating Systems
Need a hint?

Just assign the number 3 to the variable page_to_load.

3
Load the page on demand
Use a for loop with variables page and status to iterate over pages.items(). Inside the loop, check if page equals page_to_load and if its status is 'not loaded'. If both are true, update pages[page] to 'loaded'.
Operating Systems
Need a hint?

Use a for loop to go through each page and check if it matches page_to_load and is 'not loaded'. Then change its status to 'loaded'.

4
Set the page status variable
Create a variable called page_status and set it to the value of pages[page_to_load].
Operating Systems
Need a hint?

Assign the status of the page number stored in page_to_load to the variable page_status.