On Thu, May 27, 2010 at 05:41:31PM +0100, Alan Cox wrote:
Sorry, using cgroups and scheduler tricks as a race-free replacement for
opportunistic suspend.
The timeout would be at the userspace platform level. If I haven't
touched the app for 30 seconds (and if the app hasn't taken any form of
suspend block), the screen should turn off. In the current Android
implementation that will then (in the absence of any kernel-level
suspend blockers) result in the system transitioning into a fully
suspended state.
Not at all. The fact that the application hasn't taken any sort of
suspend block means that the application has indicated that it's happy
with no longer being scheduled when the screen is shut off, *providing
there's no wakeup event to be processed*.
Again, that's not the desired outcome. The desired outcome is that when
the screen shuts off, the application no longer gets scheduled until a
network packet arrives. The difference between these scenarios is large.
This is still racy. Going back to this:
int input = socket(AF_INET, SOCK_STREAM|SOCK_NONBLOCK, 0);
char foo;
struct sockaddr addr;
connect (input, &addr, sizeof(addr))
while (1) {
if (read(input, &foo, 1) > 0) {
(do something)
} else {
* SUSPEND OCCURS HERE *
(draw bouncing cows and clouds and tractor beams briefly)
}
}
A wakeup event now arrives. We use kernel level suspend blockers to
prevent the system from going back to sleep until userspace has read the
packet. The application finishes drawing its cows, reads the packet
(thus releasing the kernel-level suspend block) and them immediately
reaches the end of its timeslice. At this point the application has not
had an opportunity to indicate in any way whether or not the packet has
altered its constraints in any way. What stops us from immediately
suspending again?
--
Matthew Garrett | mjg59@srcf.ucam.org
--