Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RichP

macrumors 68000
Original poster
Jun 30, 2003
1,580
33
Motor City
Just opened my my macbook pro, which was asleep in my bag over the weekend, and the battery completely drained (no suprise there) However, when I plugged it in and opened it up, I hit the power button, and it gave me a mac gray startup screen, then a grayed out desktop with my programs running, with a status bar over it, once it was done, everything was where i left it, MUCH LIKE A PC HIBERNATE MODE. Did we inherit something here that wasnt in the PPC Powerbooks? :) My G4 never did this..
 

Vlade

macrumors 6502a
Feb 2, 2003
966
4
Meadville, PA
RichP said:
Just opened my my macbook pro, which was asleep in my bag over the weekend, and the battery completely drained (no suprise there) However, when I plugged it in and opened it up, I hit the power button, and it gave me a mac gray startup screen, then a grayed out desktop with my programs running, with a status bar over it, once it was done, everything was where i left it, MUCH LIKE A PC HIBERNATE MODE. Did we inherit something here that wasnt in the PPC Powerbooks? :) My G4 never did this..

I have the latest G4 powerbook and it does this.
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
That's the Safe Sleep that Apple added to the last batch of PowerBooks. Yep, it's basically the hibernate thing that Wintels have had for ages, but it's much faster.
 

Krevnik

macrumors 601
Sep 8, 2003
4,101
1,312
iMeowbot said:
That's the Safe Sleep that Apple added to the last batch of PowerBooks. Yep, it's basically the hibernate thing that Wintels have had for ages, but it's much faster.

Somewhat. Hibernate actually powers down the system, while Safe Sleep doesn't. Safe Sleep just means that if you lose power while it is asleep for any reason, you will be able to reboot back into the work you were doing, just like you discovered. Hibernate is really just designed to pause the machine while turning it off, saving you a startup time (in theory) or battery life if it is going to be asleep for awhile.

I noticed it myself when an Apple employee yanked out the battery to scan my MBP to get it registered for an engineering capture while it was still asleep. I would love to know what they are using to store the copy of RAM... is it something flash based, or is it a mix of software and hardware to ensure that the VM pages on the HDD can be updated at a moment's notice with what is needed to have a complete RAM image on disk?
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
Krevnik said:
I would love to know what they are using to store the copy of RAM... is it something flash based, or is it a mix of software and hardware to ensure that the VM pages on the HDD can be updated at a moment's notice with what is needed to have a complete RAM image on disk?
It's just a plain old swap to disk, OS X just does a check at boot time. If you twiddle a pair of power manglement settings, Safe Sleeps works on any modern Mac, including the desktops.

There is a little script called PatchSleep that makes enabling the feature painless.
 

Krevnik

macrumors 601
Sep 8, 2003
4,101
1,312
iMeowbot said:
It's just a plain old swap to disk, OS X just does a check at boot time. If you twiddle a pair of power manglement settings, Safe Sleeps works on any modern Mac, including the desktops.

There is a little script called PatchSleep that makes enabling the feature painless.

To get a swap to disk running that effectively though, they would need to be leveraging parts of the memory model to only dump RAM pages that have changed from the versions on disk. 2GB being dumped to disk is not as fast as this feature is. :D
 

DougBTX

macrumors newbie
Aug 20, 2005
14
0
Krevnik said:
To get a swap to disk running that effectively though, they would need to be leveraging parts of the memory model to only dump RAM pages that have changed from the versions on disk. 2GB being dumped to disk is not as fast as this feature is. :D

But do you ever see it go into hibernation?

Nope, because it happens during sleep mode, so by definition you're not around to see it. And it is Safe Sleep, not Hibernate, so you'll only ever see it pull *everything* back out of swap when your bettery dies completely. Clever design, no black screen with progress bar that you get with Windows.

Douglas
 

Kingsly

macrumors 68040
Krevnik said:
I would love to know what they are using to store the copy of RAM... is it something flash based, or is it a mix of software and hardware to ensure that the VM pages on the HDD can be updated at a moment's notice with what is needed to have a complete RAM image on disk?
My understanding is that whenever you sleep the computer it copies all the info stored in RAM to a cache on the HDD. Then if your battery dies and you plug in the computer takes the disk image of RAM and re-loads it (hence the quick progress bar) Since this is basically the same as Virtual RAM (which OSX seems to be addicted to) it is fast. I think. :D
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
Krevnik said:
To get a swap to disk running that effectively though, they would need to be leveraging parts of the memory model to only dump RAM pages that have changed from the versions on disk. 2GB being dumped to disk is not as fast as this feature is. :D
Honestly, it's pure software. The dumping isn't hard for Apple to do, because the virtual memory system already keeps track of those things. If you have a desktop Mac handy, use the little script above to enable the feature (it requires a reboot before it will take effect). Then, sleep the machine, observe the time it takes. Finally, pull the plug. on the next start, you'll see the same magic as on the late model PowerBooks and MacBooks.
 

Krevnik

macrumors 601
Sep 8, 2003
4,101
1,312
iMeowbot said:
Honestly, it's pure software. The dumping isn't hard for Apple to do, because the virtual memory system already keeps track of those things. If you have a desktop Mac handy, use the little script above to enable the feature (it requires a reboot before it will take effect). Then, sleep the machine, observe the time it takes. Finally, pull the plug. on the next start, you'll see the same magic as on the late model PowerBooks and MacBooks.

Well, it is pure software, I didn't say it wasn't. They would have to plug into the memory model and utilitize it's page tracking data to do it /fast/ though. I haven't delved into the code for XNU's memory management, but if they had code which periodically dumped stale pages out to disk, this would be easy.

I have seen the feature, and I am aware of how OSes work, being a developer working on aspects of WinCE. We use a pretty modern memory model, which has its ups and downs on such a limited platform. I was just curious as to the model Apple was using to prevent the OS from trying to dump a full RAM image every time you tell the machine to go to sleep.
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
The Darwin sources won't tell much, unfortunately, because Apple have decided to keep all the kIOHibernate* stuff private, even the header files :(
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.