pthread_mutex_trylock() should never block

Peter Kostouros kpeter at melbpc.org.au
Sat Dec 6 13:12:10 PST 2003


Hi

I have been tracking mozilla (cvs) that terminates when linked against 
libkse: basically a routine checks whether a mutex variable is locked 
with a call to pthread_mutex_trylock() before it attempts to unlock it 
with pthread_mutex_unlock(). The return value of pthread_mutex_trylock 
is checked against EBUSY and terminates the process if it is otherwise. 
In my particular scenario, pthread_mutex_trylock() returns EDEADLK: the 
pthread_mutex_trylock man page does not mention EDEADLK as an error code.

When the application is linked against libc_r or libthr, 
pthread_mutex_trylock returns EBUSY in the scenario described above.

I suppose my question is how do you safely (and quickly) check the state 
of a mutex variable?

Note, I am running FreeBSD 5.2-BETA i386 with SCHED_ULE.

-- 

Regards

Peter

As always the organisation disavows knowledge of this email




More information about the freebsd-threads mailing list