why certain apps can freeze the entire OS? If processes alternate each other by scheduler, then why computer freezes? Why it happens? How can a program/app have this “power” to do it? What are the most common reasons? Is there a way to unfreeze it? If I wait a lot, will it eventually unfreeze?


You can answer in technical ways (even though the sub says the opposite) if you want. I should understand it.

In: 3

The first thing that comes to mind would be a massive, self starting loop.

Like the forkbomb. „Copy yourself twice and start these copies“ is how I understand it. Both of these copies get the same command and generate four new copies. Those produce 8, the next generation gives you 16, then 32, 64, 128, 256, 512, 1024… you get the drift. At some point, almost 100% of the capacity will be spent to make new copies of the command. No resources are left for anything else.

It depends on the OS.

On a Linux/Mac, you have hardware process protection so it’s hard to wedge the whole OS. You can get their process number and then kill the process with a keyboard command.

On Windows, the Task Manager tends to provide a similar function. It’s been less reliable to me, but your mileage may vary.

There’s a few things that can be happening under the covers when this happens. Most programs are multithreaded, and it can be that it is executing so many things on so many threads that the CPUs all get pegged and there simply aren’t any CPU cycles available to give to the OS to let you fix the problem (looking at you Chrome 🙄). Another common cause is antivirus programs. Most antivirus software is setup to scan the file system when new files are written to make sure there isn’t anything nefarious being written. Most antivirus software that does this will have options on which directories to check, but sometimes you can have a situation where the software is writing out a large file, and the antivirus keeps detecting changes, so it keeps scanning the file as well, and then your program and the antivirus are competing for CPU and memory and disk I/O threads. And with Windows, the OS itself is a pretty big resource hog in terms of CPU and memory. So then you run into situations when you have another CPU and memory intensive program running and Windows and that program will be fighting and in some cases deadlocking over those resources. One final example I can mention, as I’ve seen this on an older windows computer I still use from time to time… similar to the antivirus is firewall software. So the firewall that I’m running there will randomly forget programs that are allowed to connect to the internet and will ask again if they can, or if it should block them. So sometimes when I wake it up from hibernating, I’ll have Chrome trying to reconnect all 20 tabs I have open, and using up all the CPU on the laptop trying to do that, meanwhile my firewall is trying to show a pop up asking if it’s ok to let Chrome connect to the internet, but it can’t because it has no CPU. When that happens, I basically need to just reboot the laptop because it’s stuck and won’t be able to get out of that situation.

Either they’re bugging the OS or just causing too much load.

In the latter case, the app is just congesting the PC. Using all the CPU cycles, memory bandwidth, etc. The OS will ensure some resources are left for itself and other processes, but it also assumes that you want the app to do that. I.e. the app is doing something difficult and needs those resources.

In the former case, the app interacts in the OS someway, either directly (i.e. by calling the APIs the OS offers apps) or indirectly (moving stuff around, using resource, etc) that cause the OS to freeze up/slow down more than it should. This shouldn’t really happen, but I’d say the most common case is an app uses so many resources that the OS slows down too much and misses something critical/appears unresponsive. I’ve seen this happen even on otherwise well maintained Linux servers.

TL;DR The OS’ job is to give apps resources to run. Sometimes it gives a little too much and it ends poorly.

1. It could be due to deadlock. Multiple app processes wait on each other to release some resource, but wait forever for an event that will never occur. For example: processes A and B require resources 1 and 2 in order to complete some operation. Process A holds resource 1, process B holds resource 2. Process A attempts to acquire resource 2, but since process B already holds it, process A waits until process B is done with it. And likewise for process B and resource 1. They both wait indefinitely.

2. It may be due to the virtual memory manager swapping blocks of data in and out of main memory excessively. When your system runs low on available RAM, it transfers data from infrequently used regions of memory to the hard drive. This effectively increases the amount of memory your system has and frees up that RAM for use. When the data that was swapped out needs to be used again, it can be moved back into main memory. However, hard drive speeds are extremely slow when compared to RAM speeds. If all of a program’s needed code and data has been swapped out, it has no choice but to wait until it’s swapped in again. But this can be true for multiple programs, and swapping one block of data into memory means swapping another block of data out of memory. It’s possible that more processor time is spent swapping data in and out of memory than executing program code.

3. Freezes can be caused by a condition known as starvation. Operating systems give each app a priority level. Apps with higher priority always run before apps of lower priorities. Some misbehaving apps can hog all of the processor time for itself, preventing low priority apps from running. Or, a high priority app may need to wait for a low priority app, but the low priority app never runs because it’s being starved.

Most operating systems today use techniques to handle these problems, but there’s no perfect solution. In general, there’s no way to know whether an app will unfreeze if you wait long enough.