Page 196 - DCAP103_Principle of operating system
P. 196

Unit 5: Memory Management



            5.12.1 Cause of Thrashing                                                             Notes

            Thrashing results in severe performance problems. Consider the following scenario, which
            is based on the actual behaviour of early paging systems. The operating system monitors
            CPU utilization. If CPU utilization is too low, we increase the degree of multiprogramming
            by introducing a new process to the system. A global page-replacement algorithm is used;
            it replaces pages with no regard to the process to which they belong. Now suppose that a
            process enters a new phase in its execution and needs more frames. It starts faulting and
            taking frames away from other processes. These processes need those pages, however, and
            so they also fault, taking frames from other processes. These faulting processes must use
            the paging device to swap pages 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.
            The  CPU  scheduler  sees  the  decreasing  CPU  utilization,  and  increases  the  degree  of
            multiprogramming as a result. The new process tries to get started by taking frames from
            running processes, causing more page faults, and a longer queue for the paging device. As
            a result, CPU utilization drops even further, and the CPU scheduler tries to increase the
            degree of multiprogramming even more. Thrashing has occurred and system throughput
            plunges.  The  page  fault  rate  increases  tremendously.  As  a  result,  the  effective  memory
            access time increases. No work is getting done, because the processes are spending all their
            time paging. This phenomenon is illustrated in the Figure 5.36, in which 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 thrashing, we
            must decrease the degree of multiprogramming. We can limit the effects of thrashing by using
            a local replacement algorithm (or priority replacement algorithm). With local replacement,
            if one process starts thrashing, it cannot steal frames from another process and cause the
            latter to thrash also. Pages are replaced with regard to the process of which they are a part.
            However, if processes are thrashing, they will be in the queue for the paging device most of
            the time. The average service time for a page fault will increase, due to the longer average
            queue for the paging device. Thus, the effective access time will increase even for a process
            that is not thrashing. To prevent thrashing, we must provide a process as many frames as
            it needs. But how do we know how many frames it “needs”? There are several techniques.
            The working-set strategy starts by looking at how many frames a process is actually using.
            This approach defines the locality model of process execution.

                                        Figure 5.36: Thrashing








                                                                   thrashing
               utilization


               CPU








                                     Degree of multiprogramming



                                             LOVELY PROFESSIONAL UNIVERSITY                                   189
   191   192   193   194   195   196   197   198   199   200   201