NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Lock Error 17500

I'm new to synchronization and believe I might have an eaisly identified problem.  Attached you will see a print screen of my problem.  The name of the image file is DeleteMe.gif.  I get an error 17500 for no apparent reason.  From the sketchy help on your website it appears that when this error is thrown its a result of two threads accessing the same resource. 
 
Tony Jocius
Test Engineer
0 Kudos
Message 1 of 4
(3,168 Views)
Tony,

A "deadlock" usually occurs when two locks get set that force both threads to wait.  If I have Lock A and Lock B that are used by two threads, then we can easily get into a deadlock situation depending on the order that we set the locks.

Thread 1      Thread 2

Lock(A)         Lock(B)
...                  ...
Lock(B)         Lock(A)

We'll get into trouble if thread 1 sets Lock A, then thread 2 sets Lock B.  When thread 1 tries to set Lock B, it will be forced to wait until thread 2 unlocks Lock B.  Thread 2 waits on thread 1 to unlock Lock A.  This causes a situation where the two threads will forever wait for the other to allow it to continue.

In order to prevent these situations, you should try to avoid embedded locks.  Also, make the amount of steps held in a lock as few as possible.  For example,

Thread 1         Thread 2
Lock(A)            Lock(A)
...                     ...
UnLock(A)       UnLock(A)
Lock(B)           ....
...                     Lock(A)
UnLock(B)       ...
                        UnLock(A)

It is difficult to see the exact cause of your problem.  Maybe you could post your sequences here, or at least give us the order that you are setting the locks in your threads.

Good Luck!

Tyler Tigue
NI

Message Edited by Tyler T. on 11-04-2005 11:35 AM

Message 2 of 4
(3,145 Views)

Tyler,
    Very interesting, and it makes sense.  I sent my sequence file to Robert Welcher at National Instruments yesterday.  I have probably several hundred locks grouped in primary locks.  Would having a unique name for each lock eliminate this problem?  I could list my locks in numerical order.  Your thoughts. 

Tony

0 Kudos
Message 3 of 4
(3,136 Views)

For a deadlock to occur, you would have to have some cycle exist.  If you always lock and unlock your locks in the same order, you can avoid deadlock.

So if you need to lock many locks for a section of code, always lock them in alphabetical order, and unlock them in reverse.


Allen P.

NI

0 Kudos
Message 4 of 4
(3,127 Views)