Day 114 - Thrashing In Memory

This will be the last post about Virtual Memory and it will be about thrashing which is condition where most of the CPU time is spent in swapping pages rather that doing actual productive computation. So let's get to it.

What Is Thrashing?

The VM allows the system to process many processes at the same time by allowing to use the secondary storage as a backing place for most of the parts of a process which then are swapped in and out of the real memory during the process execution. The VM allows the system to use more memory than it actually has with the help of a secondary storage which is mostly a hardrive or a solid-state drive.

If too many processes are working at the same time, it will cause many page faults to occur in the memory and it will happen than the CPU will be spending most of its computation time in solving these page faults rather than doing the acutal computation to complete the execution of these processes. This situtaion where the CPU is not doing work very productively is called thrashing.

Thrashing is caused by the under allocation of the minimum number of pages required by a process, forcing it to continuously cause page faults. The system can detect thrashing by evalutaing the level of CPU utilization and compare it to the level of multiprogramming and so this can be prevented by reducing the level of multiprogramming in a system.

Thrashinh Graph

Image Courtesy: CS.UIC.EDU

This above grapgh represents thrashing. From this we can see that the OS must regulate the number of active processes to prevent the onset of thrashing. That's all for today and I thing there are only two more topics left for me to study in OS and these are I/O management and Security.


zainscizainsci