Nepedia
Back to Discover
Fluent Reader
💻

Thrashing (computer science)

technology Maturity 11-13 Next article →

Computers use a special trick to handle many tasks at once. They use real memory called RAM to hold active data. When RAM gets too full, the computer uses virtual memory. This uses a hard disk as an extra layer of storage. This process is called paging or swapping. It moves data pages from the RAM to the disk.

This helps programs use more memory than is physically there. But sometimes, this system runs into a big problem. This problem is called thrashing.

Thrashing happens when the computer spends too much time swapping. A program has a group of important pages called a working set. The computer works best when this set fits in the RAM. If the working sets grow too large, page faults occur. A page fault happens when the computer needs a page not in the RAM. The system must find that page on the disk. It then moves a different page to the disk to make room.

If this happens constantly, the computer enters a state of thrashing. The CPU spends more time moving data than doing real work.

People have used this word for a long time. It started during the days of tape operating systems. Back then, it described the sound tapes made during rapid reading and writing. In the past, it could even happen on VAX processors. One specific instruction could require ten different pages to be in the RAM at once. If even one page was missing, the instruction would fail. This could cause the system to struggle deeply.

Engineers have found ways to protect systems from this. One method is called a swap-token. This is a lightweight tool used to stop thrashing. A token is given to a process that has many page faults. This process gets the privilege to use more physical memory. This helps it finish its job and release memory for others. The first version of this was put into Linux. A newer version is called the preempt swap-token. It uses a priority counter to give tokens to the right processes.

Thrashing is not just about main memory. It can happen in other parts of a computer too. It can occur in the cache, which is a very fast storage area. It can also happen in the TLB, which helps translate addresses. Even networking can experience a similar issue called silly window syndrome.

You might see your computer slow down if it is thrashing. You can often fix it by closing some running applications. This frees up the memory resources the computer needs to work properly.

430 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.