|Re: [AD] proposal: al_sleep()|
[ Thread Index |
| More lists.liballeg.org/allegro-developers Archives
On Fri, 2004-01-02 at 08:48, aj wrote:
> > And I still haven't found any reason why I would want the
> >sched_yield behavior - it just causes the CPU to heat up for no reason
> >in idle Allegro programs.
> sleep(1) on win32 tends to sleep approx 10 unless the timeBeginPeriod(1)
> is set.
> so unless the user or allegro uses the timeBeginPeriod(1) the user is not
> going to get 1ms sleep, but 10ms.
> this will cause sluggish response.
> on faster and ever faster CPU's, where we demand more processing, sleep
> 10ms is a very long time.
> (use of timeBeginPeriod(1) also has some side effects, so if allegro is to
> implement it, these side effects must be considered).
> yeild_timeslice() is not supposed to be used to sleep your app... its all
> about allowing other apps to run if they want.
> if your trying to sleep your app then use sleep(>0).
> so i think yeild_timeslice() is still a very important function.. how
> you call it ie al_sleep(0) is still a good idea.
Ok, the question is - if I'm in a loop where I don't want to give up a
timeslice - would I call yield_timeslice in it? Maybe Allegro was meant
to be used with a non-preemptive OS, so yield_timeslice() would be
important. But on the 2 OSes where yield_timeslices() currently is
implemented as stated in the docs, there is preemptive multithreading.
So if I want 100% CPU, I don't call yield_timeslice. If I have an idle
loop, I call it, and want CPU to drop to 0. So my patch always improves
Elias Pschernig <elias@xxxxxxxxxx>