LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

If can think the thread safe variable as another lock method

Hello,

 

 

Assuming that there are two threads, using a thread safe variable as a signal condition. When the 1st thread calling the GetPointerToVarName() to do something, at the "same time", the 2nd thread need to call  GetPointerToVarName() to modify something, I'd like to know if the 2nd thread can continue the work until the 1st thread call the ReleasePointerToVarName()?

 

 

David

0 Kudos
Message 1 of 3
(2,970 Views)

Thread safe variables can only be accessed by one thread at a time, so while the first one is holding the pointer, the second one waits until the pointer is released.

This is more rigid than using thread locks, in that a thread could call CmtTryToGetLock remaining free to run even if the lock cannot be acquired (supposing running without the locked object makes sense).

 

But it is not clear to me from your question whether you actually want thread safe variable functions to lock or are afraid they will do so...



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(2,962 Views)

Hi Roberto,

 

Due to just come back from Linux programming to cvi, some thread process method have confused me. Thank you for your replay.

 

 

David

0 Kudos
Message 3 of 3
(2,954 Views)