Re: [AD] proposal: al_sleep()

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


At 10:42 AM 2/01/2004 +0100, you wrote:
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).


is sleep(1)  really 1 ms ?       on which system ?
sleep(1) can actually be more harmful than yield, due to thrashing.


if you know how much sleep you need then call sleep(>0) dont go trying to change the meaning of yield.




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.)



which linux scheduler ? i dont know that much about the world of linux, but aren't there different schedulers out there ? also, how can you say you get more responsiveness when its using less CPU.. thats a complete contradiction.





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