What happens when laptop is suspended and battery runs out?

0

I would like to know what happens when I have suspended my laptop and then - say 10 hours later battery runs out as suspended state still consumes battery and power was not plugged in.

Does computer enter hibernating state (if swap available) or does it shut down and how does one control what happens? I presume ~ 5% charge remaining might trigger some processing so that computer shuts down, but how does that hapen, since in suspended state processing is generally disabled?

I run linux, but it would be good to know in principle what happens with Windows and Mac too.

r0berts

Posted 2019-02-03T20:13:20.957

Reputation: 1 585

2In Windows the behavior is usually hibernation when the battery reaches a specified percentage. It's a good idea to set that percentage in preparation for battery wear. – Tim_Stewart – 2019-02-03T20:22:21.510

1I think in some computers the BIOS will force wake the computer at 5% or some such percentage. The OS is basically inaccessible when its sleep, so an interrupt is required to wake. Whether this is Wake-On-Lan, lifting the lid, pressing the power button, or the battery dropping and the BIOS forcing a wake. Why force the wake? Because any properly configured OS would then take care of the problem and hibernate or shut the computer. The BIOS can't take care of the unsaved files etc, while the OS can't read the battery while its asleep - so it should wake and then subsequently hibernate. – QuickishFM – 2019-02-03T21:00:14.007

@QuickishFM Your comment should be a an answer – Moab – 2019-02-03T23:06:53.763

@QuickishFM I agree, this explains it well. If there is another expert who would think this to be wrong, they then could correct the answer, but your comment does answer my question. – r0berts – 2019-02-06T22:04:21.653

1It seems most likely to me anyway that this would occur, seeing as the ACPI or BIOS operates at the lower level, while the OS sleeps and it still runs and monitors the battery. I haven't any sources to use as evidence so rather than post an answer, I've simply commented it as a theory. If you would like I can post it as an answer and do further research on it. – QuickishFM – 2019-02-06T22:06:46.713

@QuickishFM - I agree it absolutely seems plausible. If you manage to get a reference or two to this it would be a great answer and I would accept it as answer without any hesitation. – r0berts – 2019-02-07T20:01:41.877

I asked my professor today and he agreed majorly with my points, that there's no way for an ACPI system to accurately save data across power losses which means its up to the OS to do so. I have provided a more in-depth answer. Sorry I couldn't provide any primary evidence or sources as I have looked online and couldn't find anything helpful quickly. – QuickishFM – 2019-02-07T20:54:34.133

Answers

1

We know that the OS can monitor the battery life by something called ACPI - this is how it gives you an accurate percentage measurement and when it knows to automatically hibernate the machine when the battery is very low. However, while the laptop is suspended, we know that the OS isn't running - it's basically paused, so it cannot monitor the battery during this time.

But while the OS is asleep, the BIOS and ACPI are still functioning in the background - they need to be on to be able to turn the computer back on whether you choose to or whether it needs to. In other words, the ACPI is constantly monitoring the battery (as it would normally) and when it hits a predefined threshold (I would guess that 5% to 10% is suitable) it activates the interrupt and forces the computer to wake up, just as you would by lifting the lid, pressing the Power, Wake-on-Lan, etc.

But won't this use more power? Yes, but only so the OS can resume, immediately see that the battery is critically low, and then save files and gracefully shut down or hibernate.

The OS cannot detect battery life when suspended, and the ACPI cannot know what data needs to be saved/dumped to the disk, so the ACPI will force-wake the PC when the battery is low and the OS should (in theory) take care of the rest.

In terms of operating systems, I would imagine that the same protocol applies to all 3 major systems (Linux, Windows and MacOS). We know it does when the battery goes low anyway, so all the computer needs to do is wake it up and let the OS take care of the rest.

Source: I haven't found a solid source on what I have said here easily online, although I did today informally ask a professor of mine who teaches embedded systems, and he agreed that the ACPI should force a wake on the system so it can take action. He mentioned that it depends very heavily on the type of system involved - a small device using a simple microcontroller (like a small number counter) may not have that complexity and just shut off on battery death, but for something like a computer there is almost always a contingency protocol for power loss. There might be ACPI advanced options in the BIOS for this very thing, but it depends between manufacturers. On my own Thinkpad I haven't seen anything of the sort so I am unable to give you primary evidence on this, but take it from my prof :)

QuickishFM

Posted 2019-02-03T20:13:20.957

Reputation: 626

I think this is a great answer about something where sources cannot easily be found + you are in the field professionally and asked your teacher, so this is quite a good exploration. I think that details may vary; I too run Linux on a Thinkpad and most likely there is a parameter (or probably simple percentage) that ACPI passes to the OS if waking up on critically low. These days Linux power management is done by Upower daemon and the config options are pretty well explained in the short /etc/UPower/UPower.conf file. – r0berts – 2019-02-08T07:25:11.630