Fundamentals 7 min read

What Really Happens Inside Your CPU When a Computer Freezes?

When a computer freezes, it isn’t simply “stuck”; the CPU may be trapped in a loop, waiting on an interrupt, or blocked by a high‑priority kernel lock, and understanding interrupts, priority levels, and kernel deadlocks reveals why a dead loop alone rarely crashes the system.

Open Source Linux
Open Source Linux
Open Source Linux
What Really Happens Inside Your CPU When a Computer Freezes?

Today I want to share an interesting question that can also expand your knowledge: what does a computer actually do when it freezes?

Everyone who has used a computer has experienced a crash, especially in the past when hardware was less powerful and running several heavy applications could easily cause a freeze. Pressing Ctrl+Alt+Delete often didn’t help, and the only option was to hold the power button.

The core of a computer is the central processing unit (CPU). In basic computer courses we learn that the CPU continuously fetches and executes instructions until the machine is turned off.

In theory there are two kinds of freezes: a hardware freeze where the CPU stops executing any instruction (rare), and a software freeze where the CPU is trapped in a piece of code and cannot proceed to the next task.

One might think that writing an infinite loop would freeze the CPU, for example:

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

Running such a loop only makes the cooling fan spin faster, but the computer continues to work; it does not freeze.

The reason is the concept of interrupts , one of the greatest inventions in computer history. An interrupt temporarily suspends the CPU’s current work so that it can handle another event, such as a timer interrupt that allows the operating system to regain control periodically and schedule other threads.

Interrupts

Because the OS installs a set of interrupt handlers when the system boots, it can periodically take back the CPU, even if a thread is stuck in an infinite loop. After the thread’s time slice expires, the CPU must yield to other processes.

Therefore, a simple infinite loop cannot crash the computer.

Even ignoring interrupts, modern CPUs are multi‑core; if one core is stuck in a loop, other cores can still be scheduled, so the system does not freeze.

When can the CPU truly become unresponsive? There are two situations:

1. Interrupts cannot preempt the CPU

Interrupts have priorities. A low‑priority interrupt cannot interrupt a high‑priority one. If the kernel mishandles an interrupt and gets stuck in a high‑priority loop (e.g., a spin lock), the CPU becomes a “plant” that does not respond to any other events.

2. Interrupts can preempt, but no thread is available to schedule

If a deadlock occurs in the kernel—such as two threads waiting on each other while holding global locks—no other thread can be scheduled, and the system hangs.

In Windows kernels, for example, a global lock held by a deadlocked thread can block all other threads, leading to a complete freeze.

Kernel deadlock illustration
Kernel deadlock illustration

Tim Chen described the situation vividly: when the kernel’s lock is held, every other thread ends up in a waiting queue, and the system becomes unresponsive.

Tim Chen illustration
Tim Chen illustration
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.

deadlockCPUOperating Systemsoftware freeze
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

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.