Re: [AD] Add timeBeginPeriod(1) to wtimer.c

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


> >>On my winXP athlon64 3000+ machine.
> >>setting the timeBeginPeriod(1) once globally  results in much better
> >>performance.  possibly due to better timing.
>
> Hence why I said: Faster CPU's may not show as much speed defficiency
> (and perhaps at some point, it'll become more efficient), but I don't
> think current CPUs are ready for it, hence why the scheduler is still
> 10ms by default.
>
> The CPU has to be fast enough, or else most of the time will be spent in
> the kenrel doing context switches than running actual user code.

Yes, and it's not up to the programmer to decide that the CPU is fast
enough (because he doesn't know what CPU the user will run his programme
on).

> Well, we can't change install_timer. Perhaps a set_timer_resolution
> function, but there's a couple problems. For one, it's Windows-only.
> AFAIK, no other OS gives such a function to user-space programs. In such
> a case, it may be just as worth it to do
>
> #ifdef ALLEGRO_WINDOWS
> timeBeginPeriod(get_config_int(...));
> #endif
>
> yourself. But my other point, user-space programs shouldn't be able to
> have such an effect on the system. Just imagine, a program sets
> timeBeginPeriod(1), then either exits forgetting to reset it, or
> crashes. The user's system will now be stuck with this alternate
> scheduler timer, potentially causing their system to lag. You don't want
> to do that.

I agree. Besides, this starts to be quite a bit of a hassle already.
Personally I think this is just too messy.

> I remember a similar problem I once had... everytime I ran Trillian on
> my 233-then-400MHz Windows macghine, my system would seem fine, but
> videos would play absolutely horrible (pretty CPU intensive on such a
> system). Even if I exited Trillian, videos would never play right until
> I reset the computer. I wouldn't doubt it did something like
> timeBeginPeriod, and neglected to reset it when done.
>
> It's one thing for a specific program to do it, but not an entire
> library.

I'm ok with calling timeBeginPeriod() at the start of rest(). Allegro
should then set a flag that timeEndPeriod() must be called. This is called
at the end of rest() and the flag cleared, and Allegro should also check
the flag from allegro_exit() or some other function registered with
atexit() so that the original behavior is restored, even if the program
crashes while rest() is active (from some other thread).
That's what I think anyway.

Evert




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