0
0
Operating Systemsknowledge~30 mins

Thrashing and working set model in Operating Systems - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Thrashing and the Working Set Model
📖 Scenario: You are learning about how operating systems manage memory. Sometimes, a computer slows down because it spends too much time moving data between memory and disk. This is called thrashing. To understand this better, you will create a simple example that shows how the working set model helps reduce thrashing.
🎯 Goal: Build a step-by-step example that models a process's memory pages and how the working set model tracks pages to avoid thrashing.
📋 What You'll Learn
Create a list of page references representing memory accesses.
Define a window size to represent the working set time frame.
Use a loop to find the working set of pages in the current window.
Show the final working set for the last window of page references.
💡 Why This Matters
🌍 Real World
Operating systems use the working set model to decide which memory pages to keep in RAM and which to swap out, preventing thrashing and improving performance.
💼 Career
Understanding memory management concepts like thrashing and working sets is important for roles in system administration, software development, and performance optimization.
Progress0 / 4 steps
1
Create the list of page references
Create a list called page_references with these exact values: [1, 2, 3, 2, 4, 1, 5, 2, 1, 3, 4, 5].
Operating Systems
Need a hint?

Think of page_references as the sequence of pages a program accesses in order.

2
Define the working set window size
Create a variable called window_size and set it to 4 to represent the number of recent page references to consider.
Operating Systems
Need a hint?

The window_size tells us how many recent pages to look at when finding the working set.

3
Find the working set for each window
Use a for loop with variable i to go from window_size to the length of page_references. Inside the loop, create a set called working_set containing the pages from page_references[i - window_size:i].
Operating Systems
Need a hint?

The loop moves a window over the page references. The working_set holds unique pages in that window.

4
Show the final working set
After the loop, create a variable called final_working_set and set it to the last working_set calculated.
Operating Systems
Need a hint?

The final_working_set shows which pages are currently in use in the last window, helping to avoid thrashing.