Thread: Mutex locks

  1. #1
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065

    Mutex locks

    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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Does this help?
    NPTL Trace Tool Project
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    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!

  4. #4
    Registered User
    Join Date
    Sep 2010
    Posts
    7
    Quote Originally Posted by Kennedy View Post
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. Mutex, Cond and Thread questions (pthread, linux)
    By thebearot in forum C Programming
    Replies: 14
    Last Post: 04-23-2010, 12:10 PM
  3. Mutex lock question
    By cjjoy1980 in forum Linux Programming
    Replies: 3
    Last Post: 07-17-2009, 10:05 AM
  4. Yet another n00b in pthreads ...
    By dimis in forum C++ Programming
    Replies: 14
    Last Post: 04-07-2008, 12:43 AM
  5. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 05:34 AM