Determining idleness when auto-suspending
- From: "Odysseus Flappington" <deriziotis gmail com>
- To: desktop-devel-list gnome org
- Subject: Determining idleness when auto-suspending
- Date: Wed, 14 Nov 2007 16:12:38 +0000
Hi all,
I'm following up an issue I brought up a while ago
regarding 'auto-suspending' the computer when idle. My argument was that there
are too many false-positives when determining the computer is idle because it is
solely up to each application to inhibit the OS from suspending when in use (https://wiki.ubuntu.com/GnomePowerManagerInhibitSpec
).
This in turn causes the computer to sleep while it's actually in use, and
happens on many occasions barring when it actually detects
kb/mouse input.
I've been quite curious in investigating possibilities
of automating the process somewhat so that GPM can automatically tell the
computer is doing something and stop the OS from sleeping when it's not supposed
to. So I went away and started off by doing some research on how Windows and Mac
OS X handle this.
Windows
According to the MSDN
(http://msdn2.microsoft.com/en-us/library/aa373233.aspx
<
http://msdn2.microsoft.com/en-us/library/aa373233.aspx) for all Win32 OSes: "As long as the system
determines that there is user or application activity, it will not put the
system into the sleep state. The system can detect certain activities, such as
user input or network communications. However, there are other activities that
the system cannot track. [...] To notify the system that your application is
busy, use the SetThreadExecutionState
function. This function prevents the system
from placing the system or the display into the sleep state while the
application is running."
The windows docs don't go into any
detail on how the OS "determines that there is [...] application activity", and
I couldn't find any info anywhere else, but the SetThreadExecutionState reminds me of Gnome's inhibit dbus method, with an added layer to detect application activity.
Mac OS X
Mac OS X on the other hand, was much more specific about how it performs these
functions. Each device on the system is classified as active or passive.
Each device driver for every active device on the system manages its own
activity and power management. A device puts itself into its lowest power state
if it is idle and every device connected to it is already in its lowest
power-state. Once all devices attached to the root system are idle, then the OS
puts the whole computer to sleep (
http://developer.apple.com/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/index.html#//apple_ref/doc/uid/TP0000011).
This seems to be a much more comprehensive solution, however, not practical for Linux since there are so
many device drivers that definitely can't implement their own power-saving policies for
whatever reason (i.e. reverse-engineered / USB devices:
http://e.kevb.net/lurker/message/20071006.200950.6940a665.en.html). Perhaps, querying a device for power-state
is a way to determine whether it's in use or not, however, I am more concerned
with the need to query devices for activity whether or not it's through its
power-state or not.
In turn, my thoughts keep going back to having a userspace application (GPM?) query each device on the system for activity, and then inhibiting the OS from suspending when it finds a device is active.
Obviously, I don't think that this has to specifically include all devices that make
up a system. For instance, checking the graphics card to see whether it's in use
would be useless since a screensaver could be using it while the computer is
idle. However, if data being transferred through the network interface, then I
should think it's safe to say that the computer isn't idle
I would at least think things like the hard-drive, network interfaces, audio devices, firewire, pc cards and usb devices can be queried at all times to see if they're in use and effectively allow the OS to automatically determine whether the computer can be suspended or not.
To conclude, I know that querying block devices (i.e. the hard-drive) for activity is a pretty trivial thing (by checking certain files in /sys). If querying other devices on a system is just as easy, would we not be interested in coming up with a mechanism to automate determining when the computer is idle? For what reasons are we not looking into this kind of solution? If it's possible, it seems like it would be a much more elegant solution than putting the ownus on every single developer that wants to write an app that will work in Gnome.
Comments and feedback welcome.
Alexander Deriziotis
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]