Re: multithreaded callbacks (was Re: [AD] de fourium pointium ohium) |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 8 Aug 2001, at 15:59, Peter Wang wrote:
> On 06 Aug 2001, Eric Botcazou <ebotcazou@xxxxxxxxxx> wrote:
> > 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).
>
> Also the behavior of pthread mutexes, and almost certainly BeOS
> semaphores (can someone else check this please?).
>
> So (probably) we might as well allow nesting.
>
POSIX thread mutexes (pthreads), do not have to be recursive. Locking a
mutex more than once in the same thread will cause undefined behavior. In
Windows, mutexes are recursive. On some unicies, they are not. Watch out
on platforms like solaris and other non-Linux unix platforms.
Gillius