03-23-2011 02:56 PM
As I understand it, in Labview the order of execution isn't defined unless sequence structures or wires define it.
The problem is shown by the picture attached... Labview doesn't define if "Foo" or "Bar" is executed first. In my application that's fine, it doesn't matter which executes first or if the order is different for every run. But, what is important is that Foo and Bar don't execute at the same time. Foo can be first, or Bar can be first, but they can't be executed concurrently. This is because both control the parallel port and send a burst of data out of it. The two burst can't overlap.
I know that I could put sequence statements around all code of this sort for the sake of safety. But, I don't want to do that because I have dozens of pieces of code like this and doing it would make my code much more difficult to read.
03-23-2011 02:59 PM
THis is what semaphores are used for. Use semaphores in the subVIs that are using a shared resource. Regardless of how teh subVIs are called the first one will get the semaphore and teh second one will try to get it but won't be able to. It will then wait for the semaphore to be released and then execute.
03-23-2011 03:02 PM
Inside your 'Foo' and 'Bar' both call a SubVI that actually send the burst out the port. Make sure this "burst" VI is non-re-entrant so which ever (Foo or Bar) calls it first, the other has to wait until the burst VI is done.
03-28-2011 05:53 AM
I've checked through my SubVIs and they aren't re-enterant. Is there something else that could cause the problem?
03-28-2011 07:05 AM
Why don't you just wire an error cluster through there. en link the VI's one after another?
03-28-2011 09:14 AM
Thanks I may try that.
03-28-2011 09:52 AM
@rthorpe wrote:
I've checked through my SubVIs and they aren't re-enterant. Is there something else that could cause the problem?
I was suggesting a (new) single VI that you create to call from inside both Foo and Bar to perform the actual bust out the port.
Not knowing what else is going on inside Foo or Bar, maybe they loop sending out multiple bust and you want Foo and Bar to run in parallel taking turns sending out a burst. An easy way is to have a NEW single VI that actually is the VI that sends out the bust from Foo and Bar and this NEW subVI is the only VI allowed to send out burst. Then Foo and Bar will only be able call this NEW sub VI one at a time and will not walk over each other's burst pattern.
But if you do not need Foo and Bar to run in parallel...
03-28-2011 10:03 AM
Thanks Omar,
I see your point. But, inside "foo" and "bar" they already use a common SubVI to perform the burst transmission, they always have I just didn't think to mention it in the first message. That VI is non-re-enterant.
I'm coming to the conclusion now that I've probably made a mistake somewhere else.
03-28-2011 11:25 AM
Is the common VI you are using have control of the parallel port?
03-28-2011 11:41 AM
Yes, it's controlling the parallel port. It uses it to send serial data to a device using the SPI standard.