Re: [AD] timer_thread_mutex

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


On 2011-07-16, Elias Pschernig <elias.pschernig@xxxxxxxxxx> wrote:
> Is there a reason timer_thread_mutex is not initialized in
> al_install_system?

I was probably wanting to keep things as modular as possible.
al_install_system is full of unrelated crap.

> The current implementation seems to have a race
> condition where if many timers are started in many threads with
> al_start_timer, several of them will think they are the first thread and
> new_size below will be 1 for multiple ones:
> 
>       if (new_size == 1) {
>          _al_mutex_init(&timer_thread_mutex);
>          _al_thread_create(&timer_thread, timer_thread_proc, NULL);
>       }

I'm surprised no assertions are tripped - it tries to lock
timer_thread_mutex before it is initialised :-P  Anyway I'll take a
look.

Peter




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