Pthread mutex lock validator

Jonathan Nieder jrnieder@gmail.com
Thu Apr 19 17:55:00 GMT 2012


sanketh nalli wrote:

> I started with this project. But i soon, realised that it may not
> be possible.
[...]
> And the custom pthread_mutex_t has to store
> some extra information to help detect recursive locking,

One way would be to keep a separate table that stores that extra
information for each (pthread_mutex_t *) value encountered.

As POSIX explains under the heading pthread_mutex_init(), the effect
of referring to copies of a mutex in calls to pthread_mutex_lock(),
..._unlock(), and so on is undefined, so the address of a mutex should
work as a key and this doesn't require any knowledge of what is inside
a pthread_mutex_t.

Hope that helps,
Jonathan



More information about the Libc-help mailing list