LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does a notifier die when the subvi that creates it returns?

I'm currently running LV 7.1 and TestStand on a dual CPU machine. I am trying to enable parallel processing to take advantage of both processors. I've created a server vi designed to process data in the background while other sequence tasks get executed. I have tried to use Jim Kring's message queues to pass commands for execution to the server. After the server has taken a message off the queue and processed it, it sends a notification that the message was processed. I pass any errors that occurred through this notifier.

Here's how it works in the sequence: a step is called which in turns calls a subvi to create the message with a built in notifier reference and place it in the server's queue. Using Jim's code, the subvi creates the notifier when the message is inserted in the queue. This subvi returns and other steps in the sequence are executed. Finally the sequence gets to another step that calls a second subvi to wait on nofication from the server before continuing on with the sequence to make sure that the background processing has been completed. The notifier refnum is passed using a global. However when the Wait on Notification vi is called, it immediately returns with a timeout, even though all timeout values have been set to -1. However if I place the Wait on Notification vi in the first subvi that creates the notifier, it works fine.

My only assumption is that the notifier dies as soon as the subvi that created it returns. I read on one thread in this forum that you should not pass notifier refnums via globals. So I modified the code so that the notifier name is passed by globals and call to Create Notifier is made to obtain a reference. However this did not work either.

The only workaround I can think of is to create a second server that simply inserts the message into the message queue for Server 1 to process and creates the notifier as well. The first subvi in the test sequence would send a message to Server 2 and would wait (probably using another notifier) until Server 2 had created the processing complete notifier. This way the notifier will not die because Server 2 continues to run. This seems to me to be way too complicated for what I'm trying to do. Does anybody have any better suggestions?

Thanks
0 Kudos
Message 1 of 3
(2,839 Views)
I tried my workaround approach. The wait for notification did not time out. However I discovered that if the wait is called after the notification is sent then that wait will hang. So it does not seem that notifiers will work for my application. I wish NI would publish a more detailed document on how their synchronization tools work so that we can save on all the time it takes for experimentation.

I think another approach might be to use a second queue in the process server, i.e. a "done" queue. When a process has been completed the server inserts a message into the done queue. I guess the message would have to contain a name to refer back to. When the sequence gets to the wait step, it waits for a message to appear in the queue. If there are already mul
tiple messages in the queue then I guess it would have to go through the elements of the queue to find a match. However, how can I remove a message from the middle of a queue? Please help!
0 Kudos
Message 2 of 3
(2,836 Views)
Hi Joe,

The only way to access the middle of a queue is to dequeue and save every element until you reach the element of interest and then use the "Enqueue Element At Opposite End" function to insert the saved elements again.

Regarding your wishes for further in-depth documentation on the Synchronization functions, I will report this as a request to our Documentation group for future improvements.

Thanks for your feedback!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 3 of 3
(2,802 Views)