MacOS – Restart automatically if the computer freezes

hangmacosreboot

There is a new option in the power management system preference to "restart automatically if the computer freezes".

How does this work exactly?

How can the computer check that it is frozen if it is, well, frozen? Is there anything else that it can still do at that point? For example, will there be a log written about this? Can there still be situations when it is so frozen that it cannot restart itself? Is there danger of accidental restarts when it is not really or only temporarily frozen? This does not happen when a single application decides to beach-ball, right?

Best Answer

The Mac models that support this have a secondary processor, independent of the CPU (it's the LOM on Intel Xserves, SMC on regular Macs). Basically, the secondary processor can have a countdown timer set up, and reset the CPU (forcing a reboot) if the counter hits 0. Meanwhile, a process running within OS X (originally it was a program called watchdog, but I think launchd handles it now) resets the counter periodically.

If the OS ever gets hosed enough that launchd/watchdog/whatever fails to reset the counter within the time limit, the LOM/SMC/etc takes over and forces a reboot.

BTW, regarding @TJ Luoma's comment on kernel panics: when a panic occurs, the OS is basically dead. There's no way for launchd to be notified of this, because it's dead along with everything else. What happens is that some information about the panic gets stuffed into NVRAM (the surviving shreds of the OS can access that without needing drivers, etc, which all went away in the panic). After reboot, the NVRAM is checked and (if appropriate) its contents are reported in the panic log.