Unit - 6
Memory Management Policies
Historically, whole processes have been moved between main memory and the swap unit via UNIX devices. Such a policy of memory protection is called swapping. Implementing such a strategy on the PDP 11, where the maximum process size was 64K, made sense. The first major implementation of a demand paging policy was the BSD method (release 4.0), which passes memory pages instead of processes to and from a secondary device; later versions of UNIX system V also allow demand paging. The whole process does not have to live in the main memory to run, because when the process references the pages, the kernel loads pages for a process on request.
Swapping has 3 components to it:
Swapping is when a main memory operation is copied to the preconfigured hard disk space, called swap space, to free up the space.
The combined physical memory capacity and swap space is the sum of usable virtual memory.
The kernel allocates contiguous swap space and primary disk space.
The free space of the swap space in an internal graph, called a map, is preserved.
When the kernel allocates resources and frees them, the map is modified accordingly.
6.1.1 Allocating Swap space
6.1.2 Freeing Swap space
Not all of the procedure pages remain in memory.
Only if the pages are remembered should pages be taken into memory.
The execution method calls for them.
As only those pages needed by the procedure are swapped from the backup store to the main memory, this is often referred to as lazy evaluation.
Benefits:
Request paging systems are more versatile in handling memory than switching systems. However, due to memory scarcity, there may be cases where the page stealer and validity fault controller thrash (spend more time on switching pages rather than method execution). The fault handler will normally sleep if the amount of the working sets of all processes is larger than the actual memory on a computer, so it does not reserve pages for a process. As all pages are in a working package, the page stealer won't be able to steal pages quickly enough. Device performance would be severely impacted.
To discourage thrashing, the System V kernel performs swapping and demand paging. The kernel wakes up the swapper and places the calling process in a state similar to "ready to run but swapped" when it is unable to assign pages for a process. Until usable memory hits the high-water mark, the swapper swaps out whole processes. It renders one' ready-to-run but swapped' process ready to run with each process swapped out. Via the standard swapping algorithm, it does not switch certain processes, but causes them to fail on pages if appropriate. This technique speeds down the fault rate of the system and decreases thrashing.
References:
1. “Unix Concepts and Administration”, Sumitabha Das, TMGH, 3rd Edition.
2. “Unix Shell Programming”, YeshvantKanetkar, BPB Publications.
3. “Unix Utilities”, Tare, MGM.
4. “Advanced Programming in the UNIX Environment”, Stevens and Rego, Pearson Education, 2nd Edition.