11-28-2018 04:28 PM
I am working on a program and I've encounter rather wired behavior for Queue in labVIEW. I attached a simplified version of my VI.
the data from Queue is somehow clear data coming from other loop. I define two identical queues to show the problem. the size of the lists is different!
Solved! Go to Solution.
11-28-2018 04:43 PM
Your code is perplexing.
Maybe it would be better to explain what you are trying to do.
mcduff
11-28-2018 05:07 PM
11-28-2018 05:55 PM
You are reading and writing to property nodes and terminals of the same controls in parallel in different loops, causing serious race conditions. This cannot end well.
What's the purpose of this exercise? What are you actually trying to do?
11-28-2018 06:24 PM
You are reading and writing to property nodes and terminals of the same controls in parallel in different loops, causing serious race conditions. This cannot end well.
What's the purpose of this exercise? What are you actually trying to do?
Yes I also believe it is a form of race condition but how I can solve it? (by the way I've used local variable same problem). I am trying to update the same string indicator is updated in several places. I think queue is thread safe so it must be string indicator. I plan to use semaphore to see if it is the problem. What is your suggestion?
11-28-2018 06:30 PM
I am trying to update the same string indicator is updated in several places.
Queues can work N to 1, that is, use multiple instances of the same queue to update the indicator. (In this case you dequeue only in 1 place)
mcduff
11-28-2018 06:50 PM
Use an action engine to maintain each list. Keep it in a shift register, no locals or value properties needed. The non-reentrant nature of the action engine protects from parallel access.
11-28-2018 06:55 PM
I am not quite sure what do you mean by Queues can work N to 1. I defined another queue and put string related to the string indicator in it and dequeue it in one places and updated the string indicator in the same place as you suggested and it solves my issue.
11-28-2018 08:33 PM
Assume multiple parts of your code update your indicator in different places. Use the same queue in those places, so you have “N” enqueue operations and you dequeue at once place, hence N to 1.
mcduff
11-29-2018 11:52 AM
@Dr--X wrote:In simple form, the program sends and receives messages from a serial ports. I defined a loop that read the serial port and put it as a string in a queue. there is another while loop which dequeue the string and put it in a string indicator. The user also send messages to serial port. So there is another event structure that send to serial port. I use same string indicator to show sending messages too.to have access to the string indicator I used property node in all this loops to access the string indicator. But when a string comes from serial port what user send in string indicator will be deleted.
What I would do is use a User Event to send a message to your Event Structure (GUI loop) for updating the indicator. You can send that event from anywhere and it will update in the order in which messages were sent.