Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens during Stand-By and Hibernation?

It just hit me the other day. What actually happens when I tell the computer to go into Stand-By or to Hibernate?

More spesifically, what implications, if any, does it have on code that is running? For example if an application is compressing some files, encoding video files, checking email, running a database query, generating reports or just processing lots of data or doing complicated math stuff. What happens? Can you end up with a bug in your video? Can the database query fail? Can data processing end up containing errors?

I'm asking this both out of general curiosity, but also because I started to wonder if this is something I should think about when I program myself.

like image 554
Svish Avatar asked May 27 '09 07:05

Svish


People also ask

What is the difference between standby and sleep mode?

Standby is known as 'sleep' mode. In 'Stand by' mode, Windows OS turns off non-essential hardware resources such as hard disk, removable disks, monitor. The system is then able to reactivate very quickly when you press any key or move the mouse. FYI - You cannot power-off the system in 'Stand by' mode.

Is hibernation same as shutdown?

Hibernation is a mid-way between shutting down your machine and putting it to sleep. I would call it shutting down, but while saving data of whatever is going on. Because hibernating uses a negligible amount of power, it is also impervious to power cuts as the data is saved to the hard disk.

What does hibernation mode do?

Hibernate uses less power than sleep and when you start up the PC again, you're back to where you left off (though not as fast as sleep). Use hibernation when you know that you won't use your laptop or tablet for an extended period and won't have an opportunity to charge the battery during that time.

What's the difference between sleep and Hibernate?

It takes longer to resume from hibernate than sleep, but hibernate uses much less power than sleep.


2 Answers

You should remember that the OS (scheduler) freezes your program about a gazillion times each second. This means that your program can already function pretty well when the operating system freezes it. There isn't much difference, from your point of view, between stand-by, hibernate and context switching.

What is different is that you'll be frozen for a long time. And this is the only thing you need to think about. In most cases, this shouldn't be a problem.

If you have a network connection you'll probably need to re-establish it, and similar issues. But this just means checking for errors in all IO operations, which I'm sure you're already doing... :-)

like image 141
Gilad Naor Avatar answered Sep 20 '22 13:09

Gilad Naor


My initial thought is that as long as your program and its eco-system is contained within the pc that is going on stand - by or hibernation, then, upon resume your program should not be affected.

However, if you are say updating a record in some database hosted on a separate machine then hibernation / stand - by will be treated as a timeout.

If your program is dependent on such a change in "power status" you can listen to WM_POWERBROADCAST Message as mentioned on msdn

like image 28
Prashast Avatar answered Sep 22 '22 13:09

Prashast