We know all that runs on the computer is a huge program collaborated by many.
So, when a computer hangs and we aren't able to do anything, what happens then? Also, is this scenario where everything freezes also something implemented in the program? or is it like the Program Counter is stuck and cannot increment and so is some problem in the processor?
The computer may freeze under different circumstances. These are the ones I can think of now:
x86 CLI
and HLT
instructions. CLI
disables interrupts, so no asynchronous event (like a timer interrupt or pressing a key) can move the CS:EIP
instruction pointer to another instruction and HLT
literally halts the processor.
The instruction is seldomly used and only allowed to by the kernel if some initialization routine in boot code fails for example. Although restarting is a better option here.
Note that HLT
only halts the core it is run on, not all cores.
A window is not responding (commonly found on Windows). This differs from application to application. More information here.
A resource is attempted to be acquired but is protected by a lock and has already been acquired. The process waits (actually busy-loops or yields another process) until it finally can acquire the resource. This is only a temporary state, though, as opposed to...
A deadlock. Multiple circumstances under which it can occur but a common one is two processes attempting to acquire resources they provide to each other at the same time. None can handle the acquisition request because both are waiting for the other processes, so both processes end up uninterruptible. This is the reason for uninterruptible processes on Linux, which cannot be killed despite being dispatched the signal to.
Multitasking on a slow processor or a processor with few threads. A bad scheduling algorithm makes the situation even worse.
Since one process occupies at least one thread, the number of processes effectively running concurrently is very low. This could be stabilized by a very fast processor, though.
This results in a long response time to events like mouse clicks.
For x86 systems, HLT
is the only instruction really hindering the instruction pointer from advancing.
All other cases are just (potentially infinite) loops or program/operating system bugs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With