HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Can a CPU be replaced without interrupting the processes running on it?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
canwithoutthereplacedrunningcpuprocessesinterrupting

Problem

When I need to replace the CPU of my computer, I turn it off, replace the hardware, then reboot it. But what if you need to replace the CPU (in a single CPU machine) without stopping the processes running on it?

Is that possible, and if so, how?

This is a theoretical question. It doesn't matter if the procedure is complicated and impractical or cost-intensive.

Solution

On a multitasking operating system, any process can be paused while other processes are executing. When a process is paused, all of its data is in RAM, outside the CPU. The CPU itself only contains a small amount of data in registers.

On a multiprocessor system, this same mechanism also allows processes (or more precisely threads) to migrate from one processor to another. As long as the processors are connected to the same RAM, a processor switch is no more complicated than a context switch.

The operating system kernel can save the few pieces of data that it normally stores in registers to a fixed place in RAM, and can make its startup code read this data back. All major multiprocessing operating systems can in fact do that: it's called suspend to RAM.

What prevents replacing the CPU during a suspend-to-RAM is not a difficulty with software architecture, but with hardware architecture. It is possible on some expensive servers, but not on a consumer device.

You can actually replace your CPU and restart with your old processes, even on a computer where this requires turning off the power, by using suspend-to-disk. Take all the data in RAM and save it to disk. This is similar to swapping. The kernel needs to do more work, because it has to power down all peripherals and restore their state afterwards. But again there is no extra theoretical difficulty, just a lot of practical difficulties in writing drivers.

Context

StackExchange Computer Science Q#112708, answer score: 3

Revisions (0)

No revisions yet.