LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview 8.2 User Class Multi-Threading

I am writing some classes with the new class type in Labview 8.2.  I like them in general but I was wondering if they protect against tampering when multithreading.

For instance, in the past I have used a queue to store class data, so that only the function that is using the data has access and another call which accesses the same data must wait for the cluster to be put back into the queue. This nicely prevents one VI from editing the class data out from under another VI.

Where I see a problem is in using this new User Class paradigm in labview 8.2. If i want to be able to inherit things from one class to the next I need access to the private data of that parent class. That can be a pain if the private data from the parent class is a queue which only had a pointer to a cluster with my data. Then what will be the additional data in my daughter class? A second queue with the daughter's private information?

Does using one VI within a user class prevent another VI within the class from writing to the private data before the first VI exits? Is there a setting that would implement this behavior. I am having trouble getting any sort of details about the working of the class system.

Kevan -
0 Kudos
Message 1 of 2
(2,441 Views)
Hi Kevan,
I believe what you are asking is if race conditions can occur with LV classes.  I did some experimenting and I believe the answer is yes.  You still need to protect your critical code.  Furthermore inside of The LabVIEW Object-Oriented Programming FAQ (http://zone.ni.com/devzone/cda/tut/p/id/3573), it states "However, when using references or any ohter means of communicating between sections of parallel code, you need to know about locking, race conditions, and other complexities that arise."  So that makes me think that using two different methods to access the same private data will not protect your code.  But because the methods are non-reentrant, you are protected from two instances of the same method changing the private data at the same time.  I hope that answers your question 🙂
Brian K.
0 Kudos
Message 2 of 2
(2,400 Views)