Re: [AD] proposal: al_sleep()

[ Thread Index | Date Index | More Archives ]

On Fri, 2004-01-02 at 11:36, Stepan Roh wrote:
> I propose this:
> 1. make yield_timeslice() sleep as little as possible on platforms not
> supporting sched_yield() or equivalent (everything except for Linux and
> Windows).
> 2. make al_sleep(0) call yield_timeslice()

Yes, that makes sense. My only concern - will al_sleep(1) release CPU?
This concern is raised by the sleeps of 30ms/10 ms inside the
yield_timeslice versions of QNX/OSX/BeOS. So, it would look like this:

al_sleep (1) -> usleep (1000);
al_sleep (0) -> usleep (10000);

That's exactly why I posted the yield_timeslice patch instead of the
al_sleep patch. And by now I still fail to see when the current
yield_timeslice in Windows/Linux is useful.

> yield_timeslice() should improve responsivness of other programs not the
> program calling it. It simply makes busy waits more polite allowing other
> programs to take a chance. And busy waits are a must in current poll-like
> input interface of Allegro.

Yes, but these busy waits also work with my new yield_timeslice version.
If I run e.g. exgui - it is as responsive as before, but uses 0% CPU.
Clearly an improvement. And I fail to see where except in the Gui code
there's any busy waits using yield_timeslice. User programs don't use
yield_timeslice normally anyway - since it has no visible effect. The
improved version OTOH gives incentive to be used, since nobody wants
Allegro programs which use 100% CPU (even though they are not event
driven - the sleeping yield_timeslice version seems to make it

Just modifying yield_timeslice (and updating the docs) seems to be the
most simple thing to do, with no need to introduce a new function.

Elias Pschernig <elias@xxxxxxxxxx>

Mail converted by MHonArc 2.6.19+