Introduction to Swapping: Policies
This lesson briefly introduces the topic discussed throughout this chapter, and also reflects on why the operating system needs it.
In a virtual memory manager, life is easy when you have a lot of free memory. A page fault occurs, you find a free page on the free-page list and assign it to the faulting page. Hey, Operating System, congratulations! You did it again.
Unfortunately, things get a little more interesting when little memory is free. In such a case, this memory pressure forces the OS to start paging out pages to make room for actively-used pages. Deciding which page (or pages) to evict is encapsulated within the replacement policy of the OS; historically, it was one of the most important decisions the early virtual memory systems made, as older systems had little physical memory. Minimally, it is an interesting set of policies worth knowing a little more about. And thus our problem:
THE CRUX: HOW TO DECIDE WHICH PAGE TO EVICT
How can the OS decide which page (or pages) to evict from memory? This decision is made by the replacement policy of the system, which usually follows some general principles (discussed in upcoming lessons) but also includes certain tweaks to avoid corner-case behaviors.
Get hands-on with 1400+ tech skills courses.