Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Driver disabling SLEEP functionality



On Thursday, February 20, 2003, at 07:32 AM, Andrew Gallatin wrote:

Wayne Flansburg writes:
On Thursday, February 20, 2003, at 07:02 AM, Andrew Gallatin wrote:

About the only thing you can do (unless you have source to their
driver) is unload their driver before going to sleep. Once their
driver is unloaded, the system should go to sleep.

I would not recommend this. Please remember that their application can
also register for sleep events and then "reject" a sleep request. You
can find an example of this in the PM DDK.

Actually, if their kext is well behaved, in theory it *should* be ok to do this. However, frequently loading and un-loading kexts is never really recommended, this is a sensitive part of the OS you're dealing with here. Besides, if they haven't added power-management to their kext, I would be concerned about their close / tear down routines in general.

Also, one minor correction to what Wayne mentioned: while applications can register for power event messages/notification, they currently can only override idle sleep, NOT forced sleep.

User space apps can only override idle sleep - these correspond to messages that ask if they "can". Appropriately enough, those messages have "Can" in their name:

- kIOMessageCanSystemSleep // in /System/Library/Frameworks/IOKit.framework/Headers/IOMessage.h

Forced sleep (and other power events) that can not be overrided by user space apps have "Will" in their name ; it's not a question, it WILL happen ;-)

- kIOMessageSystemWillSleep , kIOMessageSystemWillRestart , kIOMessageSystemWillPowerOff

So far, this is true for all shipping versions of OSX, but there's always the possibility it might change in the future.

More about idle sleep:

If the machine is sitting idle and the OS PM timers expire the OS will check w/ the kernel space clients and see if it can sleep, and then check w/ the user space clients and see if it can sleep. If no one vetos, it will sleep. A user space client can veto this idle sleep by calling IOCancelPowerChange() (in /System/Library/Frameworks/IOKit.framework/Headers/pwr_mgt/IOPMLib.h ) to a kIOMessageCanSystemSleep .

More about forced sleep:

Forced sleep is initiated in one of many ways, by user either:
- choosing sleep from menu
- pressing power button and choosing sleep from the dialog window if one pops up
- or on newer machines w/ ADC just pressing the power button on displays or the machines themselves
- running some program which calls IOPMSleepSystem() (also from IOPMLib.h)

A user side client currently can NOT veto a forced-sleep ; only kernel space tasks can override forced sleep.

Also, forced sleep can be initiated by the kernel PM system in the event of a power emergency (if battery / UPS runs low, the PM system of the kernel will put the system to sleep). I'd have to look @ the source to verify, but I believe in this scenario kexts are not even allowed to override this (it's either that or having the power cut out on you ; neither is really a good option).

For more info, check out the PM DDK and the IOKit documentation as Wayne mentioned.

-ej

Ugh. I was speaking from experiance w/my driver, and I had no idea
that sleep events could be vetoed by a user-space application. I
assume killing the application would suffice to stop its anti-social
behaviour?

Thanks,

Drew
_______________________________________________
darwin-drivers mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-drivers
Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-drivers mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-drivers
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Driver disabling SLEEP functionality (From: Andrew Gallatin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.