Virtual Memory : Thrashing

Thrashing occurs when a computer's virtual memory subsystem is in a constant state of paging, rapidly exchanging data in memory for data on disk, to the exclusion of most application-level processing. This causes the performance of the computer to degrade or collapse. The situation may continue indefinitely until the underlying cause is addressed.

We know that is is technically possible to reduce the number of allocated frames to the minimum. But if the number of pages that are in active use are more than the minimum number of frames, it will vary quickly page fault. At this point, it must replace some page. However, since all its pages are in active use, it must replace a page that will soon be needed again right away. Consequently, it very quickly faults again, and again, and again. And this process continues because every time it replaces an active page that will soon needed. This high paging activity in which a process is spending more time in paging than executing is called thrashing.

Causes of Thrashing :

Thrashing results in very serious performance problems. There are two main reason of occurrence of thrashing :-

1. The CPU utilization : Consider the following scenario, which is based on the actual Behavior of early paging systems. The Operating System monitors CPU utilization. If CPU utilization is very low it increases the degree of multiprogramming by introducing a new process to the system. A globe page replacement algorithm is used, replacing pages with no regard to the process to which they belong. Now suppose a process enters a new phase in its execution and needs more frames. it starts faulting and taking pages away from other processes. These faulting processes must use the paging device to swap page in and out. As they queue up for the paging device, the ready queue empties. As processes wait for the paging device, CPU utilization decreases.

2. Degree of Multiprogramming : The CPU scheduler sees the decreasing CPU utilization. To improve CPU utilization it increases the degree of multiprogramming. The new process tries to get started by taking frame from running processes, results in more page faults, and a longer queue for the paging device causes CPU utilization drops even further, and the CPU scheduler tries to increase the degree of multiprogramming even more. Thrashing has occurred and system throughput down to zero. The page fault rate increases enormously. As a result, the effective memory access time increases. No process progresses, because the processes are spending all their time paging.

The phenomenon is illustrated in above figure. CPU utilization is plotted against the degree of multiprogramming. As the degree of multiprogramming increases, CPU utilization also increases, although more slowly, until a maximum is reached. If the degree of multiprogramming is increased even further, thrashing sets in and CPU utilization drops sharply. At this point, to increase CPU utilization and stop trashing OS must decrease the degree of multiprogramming.

To prevent thrashing we must provide processes with as many frames as they really need "right now".

Next Topic :

No comments:

Post a Comment