sleep and hibernate?

T

Tim Slattery

Jeff T said:
What's the difference between sleep and hibernate?

When the computer sleeps, the disk, monitor, and maybe some other
things are powered down, but the RAM and CPU continue running. This
allows operations to be resumed very quickly when you wake the machine
up.

Hibernation involves writing the contents of memory to a file on the
disk and completely shutting down the computer. No power is consumed
while the machine is hibernated. When the machine restarts, it has to
go through the BIOS bootup procedure, but then it will find the
hibernate file and load that instead of going through the full OS
bootup.
 
P

Paul

Jeff said:
What's the difference between sleep and hibernate?

Sleep keeps the contents of the OS session in RAM.
Standby power (all fans stopped, some PC LEDs still
lit up), powers the RAM. On a laptop, you can see
the power LED blink once a second, when in sleep state.
If you flip the switch on the back of the computer
(or remove the laptop battery pack), and cause +5VSB
standby power to go off. the session is lost.

Hibernate stores the contents of the OS session on disk.
A bit is set on the motherboard, telling the machine to
read the disk when the computer front power button (soft ON)
is pressed. But if you turn off all PC power, the OS
still seems to be able to figure out that it needs to
read the hiberfile when it next starts. This is a
form of "warm start", in that the OS files aren't individually
read, and the one long image in the hiberfile is just
copied back to the RAM verbatim. The program counter is
restored to where execution last left off (details unknown).
When the computer does this, the PCI card state information
is not valid, so the drivers have to be warm started, to
be ready to receive commands (init the registers on the card).
So there is still an element of preparation required before
a program can continue where it left off. I'm not sure
of the details, of how the OS prepares the PCI cards
for shutdown, such that the state will be consistent
after the warm start when the next boot starts.

*******

On later OSes, there is hybrid sleep. The session contents
are kept in RAM (which takes no work or time at all). But
the hiberfile is also written, as if to hibernate. If you
press the space bar on the keyboard, and nothing untoward
happened to the power on the computer, the session continues
from S3 using the contents of RAM. The restoration is fast
because everything needed is still stored in RAM.

If, on the other hand, you accidentally switch off the power,
all is not lost. On a power up and start, the hiberfile is
consulted, and RAM is filled up again. Hybrid sleep combines
the best features of the above two. Hybrid sleep means a
slower "shutdown" phase, but the "startup" phase uses
all best-case scenarios (no session loss, no dirty file
system).

The only thing lost by using hybrid sleep, is perhaps the
user might not be able to dual boot and switch OSes when
they want. But if you sleep an OS, the expectation is,
you wanted to continue running that OS on the next session.
To change OSes, you should be completely shutting down.

Only Windows 8 gets this wrong. If you select shutdown
on Windows 8, it uses hibernation for the kernel, which
means you cannot select a new boot drive at the BIOS
level. To stop that, you have to turn off hibernation
on Windows 8, to regain your lost freedoms. So Windows 8,
to give a faster "fake" boot time, makes running more
than one OS inconvenient. A little "powercfg -h off"
can fix that. Had to do that a couple days ago, for
a new Win8 setup.

Paul
 
T

Tim Slattery

Hibernate stores the contents of the OS session on disk.
A bit is set on the motherboard,

I doubt that. I think that when the OS starts to load, after the BIOS
finishes, the first thing it does is to look for the hibernate file on
the disk. If it's there, it gets loaded. Otherwise the OS loads
normally.
 
K

Ken Blake, MVP

Quibble: "Mahatma" is a title, not a name. It's more or less "great
soul". The man's name is Mohandas Karamchand Gandhi.


I'm glad you quibbled, since you taught me something I didn't know.
 
P

Paul

Tim said:
I doubt that. I think that when the OS starts to load, after the BIOS
finishes, the first thing it does is to look for the hibernate file on
the disk. If it's there, it gets loaded. Otherwise the OS loads
normally.

Early in POST sequence, you'll notice a subtle difference.

Look at the bottom of the screen, and the BIOS ID string
is duplicated. It is repeated twice. The BIOS POST
is subtly changed in the first screen (before boot
has started).

So if hibernate was set on shutdown, the BIOS POST string
is duplicated. The string appears once, if hibernate bit
is not set, and then I'll be getting my F8 popup boot honored.

When the clear screen is done, and the second or subsequence
screens are seen, then boot starts.

So the BIOS does seem to have different behavior, and the
behavior can even manifest before SATA detection is complete.

If you don't see it, try tapping your F8 (BIOS popup boot key)
or equivalent on your system, and see if the BIOS screen
is different on the first screen, than on a non-hibernate
startup. I can tell when my F8 press is about to be ignored,
at least on a legacy BIOS.

On my new UEFI system, the BIOS has a mind of its own,
and I can't tell a damn thing about system state :-(

If you have a legacy system, you'll need to disable
"full screen logo", in order to note these text differences
between the two cases. That is the very first setting I
disable on a new computer...

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top