Re: [AD] Mini-synchronization API proposal for 4.1.x

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


On 2002-03-19, Eric Botcazou <ebotcazou@xxxxxxxxxx> wrote:
> > Is it easy to implement non-recursive behaviour in Win32?
> 
> I think that the 'lock anyway and unlock afterwards if needed' approach
> should work. But does it need to be implemented (see my question below) ?

That sounds more expensive than necessary.

> > If not, consider:
> >
> >   Note that Allegro mutexes are not necessarily recursive.  The
> > behaviour of locking the same mutex twice within a thread is
> > unspecified.
> 
> What happens if a POSIX thread locks the same (non-recursively lockable)
> mutex twice ? Is it even specified ?

Here is the glibc info entry:

 - Function: int pthread_mutex_lock (pthread_mutex_t *mutex))
	[snip]
     If the mutex is already locked by the calling thread, the behavior
     of `pthread_mutex_lock' depends on the type of the mutex. If the
     mutex is of the "fast" type, the calling thread is suspended.  It
     will remain suspended forever, because no other thread can unlock
     the mutex.

Whether the official spec has different behaviour, I don't know.



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