LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execution Order Problem

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.

 

 

0 Kudos
Message 1 of 10
(4,433 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 10
(4,428 Views)

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.

Omar
Message 3 of 10
(4,427 Views)

I've checked through my SubVIs and they aren't re-enterant. Is there something else that could cause the problem?

 

0 Kudos
Message 4 of 10
(4,383 Views)

Why don't you just wire an error cluster through there.  en link the VI's one after another?

Rommel.JPG

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 5 of 10
(4,374 Views)

Thanks I may try that.

 

0 Kudos
Message 6 of 10
(4,359 Views)

@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...   

Omar
0 Kudos
Message 7 of 10
(4,348 Views)

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.

0 Kudos
Message 8 of 10
(4,343 Views)

Is the common VI you are using have control of the parallel port?

0 Kudos
Message 9 of 10
(4,320 Views)

Yes, it's controlling the parallel port. It uses it to send serial data to a device using the SPI standard.

0 Kudos
Message 10 of 10
(4,310 Views)