Re: [AD] proposal: al_sleep()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Fri, 2004-01-02 at 12:55, Stepan Roh wrote:
> 
> I don't see the reason why 100% CPU usage is bad.
> 

Well, if something needs 100% CPU, it's not. But else, it's just wrong
to waste CPU power. Right now exmidi makes the CPU heat up as much as
compiling the kernel.. my patch makes it use 0% - the temperature stays
cool, the fans rotate slower - and I can actually here the midi :)

> > 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.
> 
> I still don't think it is needed at all - just make al_sleep(0) (=
> yield_timeslice()) sleep at most al_sleep(1) (or don't sleep at all and
> use sched_yield() or eq.). Or leave yield_timeslice() alone and make
> al_sleep(0) sleep the shortest possible time on given platform and let
> user decide if it wants non-blocking or blocking CPU release. I think
> that's the way:
> 
> 1. leave yield_timeslice() as is
> 2. make al_sleep(0) sleep the shortest possible time on each platform (it
> is sleep so it should sleep)
> 3. make al_sleep(x) sleep at least x miliseconds (or what units you have)
> 
> In this case al_sleep() should look like:
> 
> if (!x) { sys_sleep(SYS_MIN_SLEEP); } else { sys_sleep(sys_recalc(x)); }
> 

Ok, makes sense. (Of course, my next step will then be to replace
yield_timeslice with al_sleep(0) in the GUI and examples so they use
less CPU and look nicer to users.. :)

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/