LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timer of threads

hi,
 i would like to know how synchronize  two threads (While loop) which sound messages in a same time with a For loop which sends messages to these two threads.
For each Data computed, my While loops must be ready to receive it .
i explain my problem with the file  explanation.doc
 
 
TheGame
0 Kudos
Message 1 of 4
(2,909 Views)
You can use queues (Advanced>>Synchronization palette).
 
They will allow you to either keep the data even if the loops are not running in the same rate or lock the for loop (using an infinite timeout) until the while loops have removed the elements from the queues. Search the example finder and this site for examples and tutorials about queues.

___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,904 Views)

re hi,

Thanks, but my problem is that my both While Loops don't succeed in receiveing messages , because my For loop is too speed.

TheGame

0 Kudos
Message 3 of 4
(2,902 Views)

If you use 2 queues, one for each while loop, the loops will be able to catch ALL the messages the for loop places into the queue, regardless of how fast the for loop is. You also won't need any delay in the while loops because the timeout will help you with that. The problem is that if the for loop always runs faster than the while loops (let's say the for loop gets a piece of data every 1 second and the while loop takes 2 seconds to process that datat) you will get more data than you can handle and there is nothing you can do about that really.

Somehow I don't think that's the case.

Do you want to make the for loop stop and wait for the while loops?
Make the queue size 1 and the enqueue timeout infinite. That way the for loop will always have to wait until the while loops empty the queue.

Do you want the while loops to catch all the data?
Make the queue size infinite and the dequeue timeout infinite.

If this doesn't help you, you will have to post more details.


___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,893 Views)