Re: [AD] proposal: al_sleep()

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


On Fri, 2004-01-02 at 10:20, aj wrote:

> 
> >So if I want 100% CPU, I don't call yield_timeslice.
> 
> 
> correct.
> 
> 
> >  If I have an idle
> >loop,
> 
> 
> yes,   and if you know you probably will not need CPU for X milliseconds, 
> then you should call  Sleep(X)  but be aware that X's minimum value is OS 
> dependant.
> and you will have to consult the OS's documentation on its minimum sleep time.
> 
> 

Yes, so it would make sense for yield_timeslice to release CPU under
windows and linux - even though it means, a complete timeslice is given
up. All the patch does is replace Sleep(0) with Sleep(1) - and it
achieves just that - CPU drops from 100% to 0%. If I'm in a loop where I
need all the CPU power, I wouldn't call yield_timeslice - therefore the
10 ms I effectively lose don't matter. If I'm in an idle loop, and call
yield_timeslice, I don't want the CPU to run with 100% - therefore
giving up the timeslice with Sleep(1) makes more sense than keeping to
run with 100% CPU with Sleep(0).

And in Linux, my experience is that releasing CPU improves
responsiveness of my programs compared to running on 100% CPU. (I can't
explain why this would be the case though. Probably the linux scheduler
penalties apps being 100% busy, and the sched_yield doesn't change
anything in that.)

-- 
Elias Pschernig <elias@xxxxxxxxxx>





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