PDA

View Full Version : Mutex locks



Kennedy
02-04-2011, 11:04 AM
Any of you know how to determine which thread holds a mutex? This would be NPTL code that we'd be looking for (and I don't want to extend it).

Thanks!
Kennedy

Salem
02-04-2011, 12:19 PM
Does this help?
NPTL Trace Tool Project (http://nptltracetool.sourceforge.net/)

Kennedy
02-04-2011, 12:25 PM
I don't have a clue. Maybe. That may be similar to backtrace() (which is currently under development for the platform I'm on in uClibC). . . . and ewe! it is a patch to the LibC (also appears to be only available for GlibC).

I will look into it more, however. Perhaps I can port it over to uClibC and give back to the community ;).

Thanks!

gratuitous_arp
02-12-2011, 01:26 PM
Any of you know how to determine which thread holds a mutex?

I've used a wrapper function around mutex locking and unlocking calls for this purpose, basically passing the thread ID and mutex address as arguments to the wrapper, and having the wrapper keep a list of what threads have what mutexes locked. Use lookup functions to get the information you need out of the list.

Since it wasn't for anything terribly important, I didn't have to worry about offsetting timing issues when debugging, or maintaining high efficiency in production. This method may or may not be useful for you, but it is an easy way to do what you are asking.