how to find the process id of the process which locked the mutex?
how to find the process id of the process which locked the mutex?
You may or may not be able to do that at all - depends on what the OS stores within the mutex. Since mutexes are quite often used in speed-critical code, it's often determined that "debuggability" (e.g. identifying the holder of a mutex) is less important than speed. Storing extra values such as the PID in the mutex is obviously extra work that doesn't actually improve the actual workings of the semaphore.
If you are working on an Open Source OS (or in other ways, you have source for the OS), you could try to modify the mutex functions to store the PID somewhere in a part of the data structure when it's "given" to a particular process.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
My knowledge of this isn't really supreme, but here's an idea:
Can't you try and make the thread/process 'report' when it's locked with the mutex, like by modifying an array or something like that?