LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send a flag to several in parallel running loops?

Hello all,
I use two in parallel running loops that read from a RT Fifo.

I would like to offer all information to all loops instead of olny to the first one reading from the fifo (race condition).

In the attached VI both LEDs should come on and go out on every second button click "simmulataneously".

Is a RT Fifo a good solution for this problem? My final application has to run on a RT System in a timecritical loop.


Liebe Grüße
Phili
0 Kudos
Message 1 of 8
(3,665 Views)
The FIFO can only be read by one. You might consider using two FIFOs, one written for each loop at the same time in the source process. The other two loops then can each consume their own FIFO. Just use two separate names. but the same FIFO data.
0 Kudos
Message 2 of 8
(3,655 Views)
Hello Mike,
thank your for your reply.

My final application uses 6 consuming loops.
I just thought that there would be a more elegant way of solving this issue.

Would a global variable help ? Probably not as one loop would have to reset it and
I would need semaphores and additional overhead to determine when all processes have  read the flag.

Phili
0 Kudos
Message 3 of 8
(3,655 Views)

Hi phili,

The easiest way is to use property nodes.

See attached vi example.  Sorry for very messy block diagram.

The trick with using boolean & property nodes is that the button must not be latched..

Hope it helps,

JLV

 

 

Message 4 of 8
(3,641 Views)
Another option is to use a notifier to send the data out and have all the other loops subscribed to that notifier. As long as the consuming loops can keep up, you won't miss any data, but if 2 notifiers are sent before detecting them in each loop, you might miss data.

That might be another option though for you. I don't recommend using a global as each guy reading or writing the global will lock each other out while it's being accessed. (mutex lock)
0 Kudos
Message 5 of 8
(3,639 Views)
Actually, you don't want to use property nodes in RT. First, they aren't technically supported and they are VERY slow. You will get away with the example shown since it is a simple boolean value being accessed, but many properties don't work in RT and they are no where near as fast.
0 Kudos
Message 6 of 8
(3,637 Views)


@phili wrote:
My final application uses 6 consuming loops.
I just thought that there would be a more elegant way of solving this issue.

Would a global variable help ? Probably not as one loop would have to reset it and
I would need semaphores and additional overhead to determine when all processes have  read the flag.

Phili


The number of loops should not matter.  If you can, stay away from Global (or Local) variables.

When running the example, you can click on RESET and see all LEDs turn ON or OFF simulataneously.  It's a rough running vi that is simply meant to illustrate a very simple solution.

As for using Semaphores, it depends... do you want to execute one thread while others wait or do you want all to run simultaneously in parallel?   I am not sure how you want to use this, maybe if you describe the issue a bit more.  😉

JLV

 

OOPS!!

My mistake!!  (Not enough coffe thismorning!)  yikes..

Sorry.  I missed the RT system... OK..

Yes, in this case maybe using notifiers would be a better way. 

Not globals..

JLV

Message Edited by JoeLabView on 03-20-2006 01:11 PM

Message 7 of 8
(3,637 Views)
Hello Joe and Mike,
thanks again for your help and your replies.

Joe, I tried the property nodes you described, but as Mike pointed out my system does no longer catch up with the RT condition.
Hence I dropped them again.

I will look at notifiers now. Have never heared of (still pretty new to LV).

I will probly not need semaphores as a do not want the loops to wait for each other. They are still somewhat separate.

Till later,
Phili
0 Kudos
Message 8 of 8
(3,628 Views)