- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using a mutex to synchronize the queue's access by threads. I need to find out who is waiting for the lock to retrieve messages when a message arrives. Anyone knows how to find out who is waiting on a mutex lock?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The handle on a Mutex may be the address of an opaque structure. In the debugger you can view the memory, as DWORD or QWORD, at the address indicated by the Mutex handle. Observe any changes across WaitForSinglObject that obtains the lock. Also, observe any changes across a ReleaseMutex. By this observation you might be able to descern some useful information. i.e. is the thread ID of the owner of the lock stored in the opaque structure? It might not be. The waiting threads may be stored in a list, whos list head is in the opaque structure.
Using values derived from an opaque structure is generaly not advised in a release version of an application (the contents of the opaque structure are subject to change with new versions of the OS).
A better route is for you to write a wrapper function to lock and release theMutex. This wrapper function can then insert and remove an identifier of your design.
Depending on your design requirements a hybrid approach might be advised. e.g. the queuing threads don't suspend on insert of message, but the retrieving thread blocks onlyon empty.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From my prior message
>>
A better route is for you to write a wrapper function to lock and release theMutex. This wrapper function can then insert and remove an identifier of your design.
<<
Since you "rather a way to do it in the program" you therefor can program the Mutex lock and release functions. Make a function that you call to perform the lock and release but additionaly save the thread identification information.
If you are not in control of all the programs the perform the locks then you would be unable to insert the identifier information. On the other hand if everyone is running different instances of the same program then you only need to add the identifyer tracking in one application.
Jim
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page