Re: [AD] uthreads.c revisited |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Tue, 2004-07-13 at 19:53 -0700, Chris wrote:
> I'm just going through this in my head... in the threaded background
> process manager for input and sound, we have this:
>
> /* run the callbacks for each 10ms elapsed, but limit to 18ms */
> if (interval > 18000)
> interval = 18000;
> while (interval > 10000) {
>
> However, I think I may have an issue or two with it. First off, I
> understand that the interval is clamped to 18ms so it doesn't run away
> due to a cpu spike or process pause or something. But, I'd want to ask
> if clamping is necessary? And if it is, I think it should be changed to
> something like this:
>
> if (interval > 20000)
> interval = 20000;
> while (interval >= 10000) {
> or
> if (interval > 18000)
> interval = 18000;
> if (interval >= 10000) {
>
> In both cases, the bg processes run when the interval is >= 10ms,
> instead of only > 10ms. For the first, it increases the max clamp value
> to 20ms, so the while loop would run twice if it was that far behind
> (this could be what the original clamp was aiming for but due to
> MAX_INT, couldn't get higher than 17.99ms). For the second, it changes
> the while to an if, since even if interval was 20ms or more, it would've
> been clamped to 18ms and the while loop would only run once anyway
> (granted optimizations would clear this out, but it doesn't look very
> clean).
>
Not sure. Using 18000 vs 20000 is completely arbitrary. Maybe we
actually set it even higher, sometimes my HDD seems to block the
complete system for something like half a second it seems :| And the
while vs if, if there's no while, we are limited to whatever is the
timeslice time at which select() returns. I think we can safely leave it
as it is now.
--
Elias Pschernig