Re: Correct way for an application to sleep?

From: Jan Engelhardt
Date: Thu Mar 01 2007 - 20:44:25 EST



On Feb 24 2007 21:54, Sindre AamÃs wrote:
>
>Without root-privilegies, that leaves general purpose sleep functions
>like nanosleep afaik. The problem is that the granularity of these
>seems very unpredictable, and if I am to use a lowest common
>denominator I'd only be able to sleep like 10 ms pr 16.7 ms on fast
>systems, and not at all on not so fast systems. So, I'd like to know
>what the "correct" way to handle this kind of situation is, if any,
>from a kernel perspective. Is the only sensible thing to do to give a
>user settable preference, deciding on a compromise default (or one
>that says "screw you old kernels")?

You could use an adaptive sleeping ('overhead-corrected'), but I do not
know how well it works with asynchronous events (such as audio output).
Take a look at the usleep_ovcorr() function in
http://ttyrpld.svn.sf.net/viewvc/*checkout*/ttyrpld/trunk/user/replay.c


Jan
--
ft: http://freshmeat.net/p/chaostables/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/