Re: multithreaded callbacks (was Re: [AD] de fourium pointium ohium)

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


> "MUTual EXclusion" seems pretty neutral to me.

Mutex is a rather well-defined term for inter-process synchronization and I
don't know if our own "mutexes" would perfectly fit into this definition
(see below).

> But they can be used to do the same job, right?

Yes, but only for threads of a single process (contrary to mutexes).

> Btw, the BeOS version would use semaphores.

This makes me think: which semantics to choose for these "mutexes" regarding
multiple locking ? The way the mini-API is currently designed
(acquire_mutex()/release_mutex()) might suggest to use the same semantics as
acquire_bitmap()/release_bitmap(), that is multiple acquire calls can be
nested and the "mutex" will be truly released only if the lock count returns
to zero (this is the behaviour of Win32 mutexes and critical sections).

> True.  Since they wouldn't be used a *lot*, maybe in `allegro.h':
>
> void *allegro_create_mutex(void);
> void allegro_destroy_mutex(void *);
> ...
>
> #ifdef ALLEGRO_MUTEXES
>
>    #define create_mutex()      (allegro_create_mutex)()
>    #define destroy_mutex(mtx)  (allegro_destroy_mutex)(mtx)
> ...
>
> #endif

It looks like this problem is well beyond the scope of these 4 little
functions...

---
Eric Botcazou
ebotcazou@xxxxxxxxxx



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