Fundamentals 6 min read

Why Your PC Freezes: Interrupts, Infinite Loops, and Kernel Deadlocks

The article explains that computer freezes are usually caused by software-level issues where the CPU gets trapped due to interrupt handling or kernel deadlocks, rather than hardware failure, and shows why a simple infinite loop cannot crash a modern operating system.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Why Your PC Freezes: Interrupts, Infinite Loops, and Kernel Deadlocks

Most computer users have experienced a freeze and wonder what the CPU is doing at that moment. While a hardware‑level CPU halt is theoretically possible, it rarely occurs; most freezes are software‑level when the CPU becomes unable to progress.

Consider a classic infinite loop:

void dead_loop() {
    while (1) {
        ...
    }
}

Running this code does not freeze the machine because modern operating systems use timer interrupts to preempt the running thread, allowing other tasks to execute.

Interrupts

Interrupts are one of the most important inventions in computer history. The OS installs a set of interrupt‑handling routines (e.g., the clock interrupt) that periodically regain control of the CPU, schedule other threads, and ensure the system remains responsive.

When a thread enters an infinite loop, its time slice eventually expires; the scheduler forces the CPU to switch to another runnable thread.

Therefore, a simple infinite loop cannot crash the computer; the OS would simply preempt it.

Even on multi‑core CPUs, a single thread stuck in a loop does not freeze the system because other cores can continue to be scheduled.

However, the CPU can become truly unresponsive in two situations:

Interrupts cannot preempt the current code – Interrupts have priorities. If the kernel disables interrupts or a high‑priority interrupt handler enters a dead loop (e.g., due to a spinlock), lower‑priority interrupts cannot break in, leaving the CPU stuck like a “plant”.

Interrupts are handled but no runnable thread exists – A kernel‑level deadlock (for example, two threads waiting on each other or a lock held while processing an interrupt) can leave the scheduler with no eligible thread, causing the whole system to hang.

The first diagram illustrates how the CPU can be trapped when an interrupt handler fails to release a lock.

Tim Chen’s description (shown below) visualizes a kernel deadlock where the system cannot schedule any thread.

In summary, a computer freeze is usually the result of the OS being unable to regain control of the CPU because of interrupt priority issues or kernel‑level deadlocks, not because the CPU itself has stopped executing instructions.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

deadlockCPUsoftware freeze
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.