One of the frequent problems that is encountered during memory management is thrashing.
– This problem usually occurs when the virtual memory subsystem of the computer system is in a state of constant paging.
– The data is rapidly exchanged to and fro between disk and the memory.
– All this is done excluding a major part of the application level processing.
– This results in a major degradation in the performance of the system or it may even collapse.
– This system might suffer from this situation indefinitely if the cause of the situation is not discovered and addressed appropriately.
– If there are not enough pages for a process, then thrashing will occur and also the page fault rate of the process will be high since it is a high paging activity.
– This puts the CPU on low utilization phase.
– In most of the modern computers, if the disk access time is taking too long or if the physical memory is not sufficient, then the paging system might experience thrashing.
– Thrashing may also occur in the telecommunication systems where there are frequent conflicts concerning the internal bus access.
– Depending on what is the algorithm used by the system and its configuration, its latency and throughput may suffer degrading through multiple orders of magnitude.
– Thrashing is also common in the virtual memory systems where it may be caused by the workloads or programs having locality of reference that might be insufficient.
– It may also occur in case the workload or the program cannot be held effectively in the main memory.
– Thrashing is also known as constant data swapping.
– The term ‘thrashing’ first came in to use in the days of the tape operating systems.
– The older systems that were typically low end computers did not have sufficient memory or RAM to be used as per the modern usage patterns.
– If the main memory of the system is increased, no doubt it can run relatively fast.
– Since the space increases, the amount of swapping required decreases thus causing a rise in the overall speed of the system.
Process of Thrashing
The process of thrashing can be explained as follows:
– Process to be executed requires more memory than what the processor has.
– The system uses the paging technique. Each time it brings in a page and the previously referenced page is thrown out.
– Most of the time of the processes will be spend being blocked and waiting for the operating system to fetch the pages from the secondary memory.
– Processes often refer the page that is not there in the main memory. There might be three different reasons for this: memory is not reused by the process or even if the process reuses the memory, it is not sufficient or there are too many other processes using the memory as well.
– Process when short of pages, gives rise to a page fault which gets very high eventually if the shortage persists. Most of the time of the operating systems is spend in swapping the pages in and out of the main memory.
What is actually required in today’s computers is virtual memory whose access time is same as that of the physical memory and whose size is that of the disk. When thrashing occurs operating system can’t actually do anything except for containing the damage.
A solution would be to change the scheduling algorithm or the priorities so that the processes whose memory needs can be satisfied can be executed.