LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

cmtgetlock causes freeze - Is there a way to see who is holding the lock?

My program is sitting at cmtgetlock forever and not sure why.  I stepped through all my code and don't see anythign obvious. My CMTGetLock is called after a user callback button.

 

Is there not a way in CVI to investigate a semaphore deadlock?

0 Kudos
Message 1 of 5
(3,299 Views)

I see I can add the function call to get the thread id of who has the lock, but didn't see anythign in regards to debugging that says it.

 

PS I did find my bug after figuring out the thread, then adding a breakpoint there.

0 Kudos
Message 2 of 5
(3,295 Views)

So you were able to resolve the issue of your code freezing at the cmtgetlock function? Are you directly calling this function from the callback without using any sort of thread pool or multi threading capability?

Ian M.
National Instruments
0 Kudos
Message 3 of 5
(3,272 Views)

My program has a few threads running.  I ended up solving it by adding the getID function calls before the lock up and then viewed threads actively in my debugger.

 

What I was looking for was a way to view the holding thread of the lock in the debugger but couldn't see how to do that.

0 Kudos
Message 4 of 5
(3,269 Views)

If you're using a CmtThreadLockHandle, and you're using CVI 2009 or later, you should be able to view the owning thread of a lock. For example, this is what the Variables window shows me, when I debug the ThreadLockTimeout example:

 

lock.png

 

0 Kudos
Message 5 of 5
(3,258 Views)