SEARCH

How-To Geek

How Is My Computer Able to Restart Itself?

It’s such a common place activity that most of us have likely never stopped to even think about it: the automatic restart. Whether user or application-initiated, what exactly happens when your computer cycles its own power?

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-drive grouping of Q&A web sites.

The Question

SuperUser reader Seth Carnegie wonders about computer power management:

How can a computer restart itself? After it’s off, how does it tell itself to come back on again? What kind of software is it that can do this?

How indeed? What combination of software/hardware magic makes it happen?

The Answer

SuperUser contributor Jcrawfordor offers both a condensed and detailed response to the question that more than adequately addresses the question:

The too long;didn’t read it answer: Power states in your computer are controlled by an implementation of ACPI (advanced configuration and power interface). At the end of a shutdown process, your operating system sets an ACPI command indicating that the computer should reboot. In response, the motherboard resets all components using their respective reset commands or lines, and then follows the bootstrap process. The motherboard never actually turns off, it only resets various components and then behaves as if the power button has just been pressed.

Long and rambling but (in my opinion) more interesting answer:

Soft Power and How It Works

In the olden days (well, okay, to a college student like me the ’90s was a long time ago), we had AT (Advanced Technology) motherboards with AT power management. The AT power system was very, very simple. The power button on your computer was a hardware toggle (probably in the back of the case) and your 120vac input went right through it. It physically turned the power to your power supply on and off, and when this switch was in the Off position everything in your computer was completely dead (this made the CMOS battery very important, because without it there was no power supply to keep the hardware clock ticking). Because the power switch was a physical mechanism, there was no software way to turn power on and off. Windows would show the famous “It is now safe to turn off your computer” message because, although everything was parked and ready to turn off, it was not possible for the OS to actually flip the power switch. This configuration was sometimes referred to as hard power, because it’s all hardware.

Nowadays things are different, because of the wonders of ATX motherboards and ATX power (that’s Advanced Technology eXtended if you’re keeping track). Along with a number of other advances (mini-DIN PS/2, anyone?), ATX brought soft power. Soft power means that power to the computer can be controlled by software. This brought a few import changes:

  • Standby power: you may have seen a “5v SB” or “5v standby” connector labeled in power supply pinouts. The standby power supply is a 5v line to your motherboard that is always on, even when the computer is turned off. This is why it is important to unplug or turn off a PSU hard switch (if present) when servicing modern computers, because even when it’s off you could potentially short the 5v SB and damage the motherboard. This is also why CMOS batteries aren’t really as important anymore – the 5v SB is used to replace the CMOS battery whenever the power supply has mains power, so the CMOS battery is only used when you unplug the computer entirely. The 5v SB line importantly allows components of your computer (most importantly the BIOS and the network adapters) to keep running some simple software even when the computer is turned off.
  • Intelligent power supply control. If you look at a pinout for your power supply’s motherboard (P1) connector, you’ll notice two pins typically labeled PS_ON and PS_RDY. These stand for “power supply on” and “power supply ready”. If you like to experiment, take a power supply not in a computer, plug it in, and carefully short a ground line (one of the black wires) to the PS_ON line (the green wire). The power supply will visibly turn on, with the fan spinning up. The components of the motherboard running off of +5v SB actually turn your power supply on and off by connecting power to the PS_ON pin. Because there are some capacitors and other components in the power supply that take a moment to charge up, the voltages from the power supply’s main outputs may not be stable immediately after the PSU turns on. This is what the PS_RDY pin is for, it comes on when the power supply’s internal logic determines that the power supply is “ready” and will provide stable power. The motherboard waits until PS_RDY is on to continue booting.

So, your power switch no longer “turns on” the computer. Instead, it’s connected to your motherboard’s basic controllers, which detect that the button has been pressed and execute a number of steps to ready the system, including lighting up PS_ON so that power will be available. The power button isn’t the only way to trigger the startup process, devices on your expansion bus can also do so. This is important because your ethernet network adapters actually stay on when your computer is off and look for a very specific packet often referred to as the “Magic packet.” If they detect this packet addressed to their MAC address, they will trigger the startup process. This is how “Wake-on-LAN” (WoL) works. The clock can also initiate a boot (most BIOS allow you to set a time that the computer should boot each day), and USB and FireWire devices can trigger a boot, although I’m not aware of any implementation of this.

Understanding Power Control

Well, I explain the Soft Power thing both because I think it’s interesting (always a key reason that I explain things) and because it allows you to understand how the power and running/off state of your computer are all controlled by software. In most current computers, this software system is an implementation of the Advanced Configuration and Power Interface, or ACPI. ACPI is a standardized, unified system allowing software to control your computer’s power system. You may have heard of the ACPI power states. The basic mechanism of power control is these “power states”, your operating system switches through power modes by preparing for the switch (the shutdown/hibernate processes that occur prior to power actually flipping off), and then commanding the motherboard to switch power states. The power states look like this:

  • G0: Working (your computer’s “on” state)
  • G1: Sleeping (your computer’s standby states, divided in to the S substates)
    • S1: power to CPU and RAM remains on, but CPU is not executing instructions. Peripheral devices are powered off.
    • S2: CPU powered off, RAM maintained
    • S3: All components powered down except for RAM and devices that will trigger a resume (keyboard). When you tell your OS to “Sleep”, it will stop processes and then enter this mode.
    • S4: Hibernation. Absolutely everything is turned off. When you tell your operating system to Hibernate, it stops processes, saves the contents of RAM to disk, and then enters this mode.
  • G2: Soft Off. this is your computer’s “off” state. Power is off to everything except for devices that can trigger a boot.
  • G3: Mechanical off.

How reset actually happens

You’ll notice that reboot is not one of these states. So what actually happens when your computer when it reboots? The answer may be surprising, because from a power management perspective it’s almost nothing. There is an ACPI reset command. When you tell your operating system to reboot, it follows its normal shutdown process (stops all your processes, performs a bit of maintenance, dismounts your file systems, etc), and then as a final step, instead of sending the machine to power state G2 (as it would if you had simply told it to Shut Down) it sets the Reset command. This is generally referred to as the “Reset register”, because like most of the ACPI interface it’s just an address that a specific value should be written to in order to request a reset. I’ll quote the 2.0 specification on what it does:

The optional ACPI reset mechanism specifies a standard mechanism that provides a complete system reset. When implemented, this mechanism must reset the entire system. This includes processors, core logic, all buses, and all peripherals. From an OSPM perspective, asserting the reset mechanism is the logical equivalent to power cycling the machine. Upon gaining control after a reset, OSPM will perform actions in like manner to a cold boot.

So, when the reset register is set, a few things happen in sequence.

  • All logic is reset. This means sending the respective reset commands to various bits of hardware including the CPU, memory controller, peripheral controllers, etc. In most cases this simply means lighting up a physical RST wire, as AndrejaKo showed up above.
  • The computer is then bootstrapped. This is the “perform actions in like manner to a cold boot” part. The motherboard performs the same steps as it would if the power supply had just become ready after the power button being pressed.

The end effect of these two steps (which actually break down in to a lot more steps) is that it looks to everything just like the computer just booted, but the power was actually on the whole time. This means less time required to shut down and start up (since you don’t have to wait for the power supply to become ready), and importantly allows the bootup to be initiated by the operating system shutting down. This means that another startup trigger doesn’t need to be used (WoL etc), and allows you to use Reboot as an effective way to reset the system remotely, when you don’t have a way to trigger boot.

That was a long answer. But hey, hopefully you know more about computer power management now. I certainly learned some things researching this.


Have something to add to the explanation? Sound off in the the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

Jason Fitzpatrick is warranty-voiding DIYer and all around geek. When he's not documenting mods and hacks he's doing his best to make sure a generation of college students graduate knowing they should put their pants on one leg at a time and go on to greatness, just like Bruce Dickinson. You can follow him on if you'd like.

  • Published 10/23/12

Comments (16)

  1. David

    Very nice read, even for someone who knows how it works. I will be keeping this as a bookmark for giving to friends when they ask me computer questions. :)

  2. Fred

    Excellent read! But what does Windows doing to execute some command after it has installed some update to the OS. Sometimes after one of these updates and reboot the system goes thru some kind of configuration steps…how does it know to do this on reboot.

  3. Lee

    @Fred: I’m assuming that, before rebooting the machine, Windows adds the needed commands to some kind of lower-level startup list (like the list in msconfig but it must be executed before that list because it happens before you log on).

  4. Uncle Nutzi

    Thanks for very informative article. It helped clarify some things and exposed others.
    It gave me reason and understanding of switch on P/S. I always turned it off to work on computer and unplugged cord to be double-safe not to charge motherboard.
    Explanations of terminology is appreciated also.

  5. Ashish

    nice description.

  6. Soul

    Great article, thanks for it.
    Never really cared or appreciated much of the computer’s power management till this.

  7. Paul

    Interesting article. I’m not aware of any USB-controlled boot implementations either, though power-managed uninterruptible power supplies (UPS) can initiate shut down via their USB connection to the machine they’re powering.

  8. Ron

    So why can my older desktop wake itself up to execute scheduled tasks when hibernated, but not when it’s off? Aren’t those the same state, from the point of view of the BIOS?

  9. john3347

    Ron, maybe you are about to understand what a farce hibernation is. Hibernation does not shut your computer down, it saves open applications and goes into a “low power mode”. If you unplugged your computer while in hibernation, or your house lost power, it would lose all saved applications.

  10. Nathan

    Very interesting and timely article. I have an HP 8560w laptop for which neither the ACPI Reset (for reboot) nor G2 state works (for shutdown). I’m running Win7 64-bit Enterprise. In both cases, Windows shuts down and the screen goes blank, but the keyboard lights (num lock) stay on and the fan continues to run and blow pretty hot air, like the CPU is stuck in a busy loop. It will stay this way for hours until I hold down the power button for 5 seconds to cut power or I remove the battery.

    HP just released new firmware for this model (F.28) which made no mention of power issues and did not fix this problem.

    Any ideas here?

    Thanks

  11. Tim S

    @john3347 – Not true. Hibernation dumps RAM to disk – that way it can restore your session regardless of you pulling the plug. Sleep does not, and hybrid sleep actually is a combination of both where your memory is saved just in case your RAM was fully powered off (and if it wasn’t resume is instant-ish compared to resuming from cold where it has to reload what was in the RAM before resuming).

  12. Tim S

    @Ron – it depends on the states your bios/motherboard supports. For example my HP Microserver doesn’t support sleep at all so it’s impossible to have it auto power down (and still remain ‘wakeable’ via the network). My Media Centre does – and thus will happily go to sleep when idle and then wakeup to record TV on schedule.

    open a command prompt and type:

    powercfg -a

    It will report which states are available for you (assuming Win 7)

  13. Toxigen

    All very nice, but how do I stop my XP machine from re-starting EVERY TIME I try to shut down?
    VERY annoying

  14. Phil Manley

    In the example above, probing an earth on a certain pin & power supply (it is claimed) will start up …
    It may not startup. Many power supplies require some sort of electrical load on the p/s before it will startup. So a 12V lamp or similar has to be attached to the 12V line if you expect the power supply to start up.

  15. Tim S

    @Phil – bridging two pins on the PSU mb header always works (and has done for some time) for me on various PSUs – but it’d be a bit odd to try starting one without something attached anyway..

  16. Harry Sherman

    As I understand it from the above, G-2 is when the computer is shutdown with the front power switch, and G-3 is when the computer is unpluged or turned off with the power switch on the back. My question: In the G-2 state when connected to an always-on router, can the computer be booted by an external command from malware or a virus?

Enter Your Email Here to Get Access for Free:

Go check your email!