3

I like to know how exactly suspending proceeds in Ubuntu,

  1. Is any hardware completely cut from power or their process is just minimized?
  2. Other than the screen which parts are put on hold or their power is cut off?
  3. If there is any power consumption when suspended, how can I know how much it is and how long I can expect my laptop to be able to be revived before battery is drained?
  4. What happens exactly for hard disk and is it safe to carry around the laptop without damaging the hard disk when suspended?

1 Answer 1

9

When a machine goes into the suspend state the kernel freezes (stops) user space programs and kernel threads. Then the kernel will traverse all the devices and calls the suspend methods on each driver. Each driver has the know-how to put the hardware into a deep sleep state (or even power it off) (and the converse to bring it back to a sane running state when the resume occurs). At this point the hardware should be in a low power state (and hence the Hard Disk will be powered off).

The Kernel wakeup code address is written to an address as specified by an ACPI FADT table, then x86 Power Management Control registers are written to; this effectively powers off the processor but keeps memory in a self-refresh mode.

When resume occurs, the CPU is restarted and after a short time in the firmware (BIOS/UEFI) jumps to the wake up address provided by the kernel and the kernel jumps back into protected mode and restores its state. It then traverses the drivers and these resume all the devices. Then frozen processes are thawed and the kernel returns back to user space.

So to answer your questions:

1 and 2: Devices drivers try to put devices into the deepest sleep state, some devices can be powered down, some may be just in the deep sleep state consuming very little power. It depends on the hardware and the device driver.

Memory is being refreshed, it is never powered off. The CPU is effectively stopped, but it depends on the CPU model on how much of the package is actually fully powered off.

  1. One way to determine how much power is being uses is using the Firmware Test Suite s3power tests; I recommend putting the machine into deep sleep for 30 minutes and measuring battery power drain to get an estimate of power usage during suspend:

remove AC power supply, then run:

sudo apt-get install fwts
sudo fwts s3power --s3power-sleep-delay=1800

..wait 1800 seconds (30 minutes) and it should power back on and give an estimate.

  1. The hard disk is power off, so the machine is safe to be carried.
1
  • For a complete answer of the question in the heading, I'd expect also to learn about how Ubuntu decides when to go to suspend. There seems to be some kind of activity tracker and counter how long there was no activity. What activities reset the inactivity counter? Where can this be configured or extended, e.g. to cover scheduled activities in a program running in the background? Oct 13, 2023 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .