find the process id

This is a discussion on find the process id within the C Programming forums, part of the General Programming Boards category; how to find the process id of the process which locked the mutex?...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    find the process id

    how to find the process id of the process which locked the mutex?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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.

  3. #3
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    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?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by IceDane View Post
    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?
    If you have the code (and are willing to modify it) for the thread holding the mutex, then yes.

    --
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  3. Retrieving binary file name from a process
    By maxhavoc in forum Linux Programming
    Replies: 5
    Last Post: 04-12-2006, 02:50 PM
  4. passing a connection to another process.
    By Kinasz in forum Networking/Device Communication
    Replies: 3
    Last Post: 10-09-2004, 05:34 PM
  5. Replies: 12
    Last Post: 05-17-2003, 05:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21