07-31-2009 05:07 PM
Hi,
I have a case with semaphore vis getting stuck (deadlock) waiting for each other.
I have 2 dynamic VIs.
The first one, called sendprocess.vi, sends continously messages to CAN at different rate. So I used parallel time-loops with different interval times. Each of these loops has a semaphore to guarantie that there is only one loop can send data to CAN at a time.
The second one, called receiveprocess.vi, receives messages from and send back some asynchronous message. Cause it also using send CAN function so I also use semaphore to guard it.
After runing for couple of seconds, all of these semaphores get stuck.
I would appreciate any helps or suggestion of another architect which make it runs better.
Best regards,
Thang Nguyen
08-01-2009 01:19 AM - edited 08-01-2009 01:22 AM
I don't see anything blazingly obvious despite the fact your pics overlap.
Are you sure you have no other code trying to acquire semaphores? (any at all).
By the way, your case statements will never execute the TRUE case with the timeout on the Acquire set to the default of -1 (meaning Acquire will hang waiting for the semaphore as long as it takes as you have observed).
08-01-2009 01:59 AM
If you click zoom, you will see those semaphores get hang waiting with a green arrow. I have to turn on the highlight to show wat is going on. I can see it run for 5, or 6 time boths VI before all of them get hang. They can send and receive message as I expected. The right side is the VI which is called inside the receive VI and is executed when the receive VI response. The leftside is 3 timeloop sending out continously at different rate. I don't use time out, because I want them to wait until turn to execute the sending command. I have to keep the rate correctly because my system interact with a real time system.
Best regards,
Thang Nguyen
08-01-2009 02:06 AM
Yes, I saw all that. But you didn't answer my questions: Do you have any other code that acquires a semaphore? Have you tried turning debugging on to get an idea where the problem is?
08-01-2009 10:23 AM
In sendprocess vi I have 3 loops using semaphore. In receiveprocess vi, I have different subVIs which is call asynchronous to response to different request. So there is only one of these VIs will be call at a time. As in my picture, there are totally 4 semarphore considered to be working together at a time.
What you mean by turning on the debug? I use high light to check wat is going on.
08-01-2009 01:24 PM
Yes, execution highlighting as below.....did it run? What was the result? If you get the same indications, you should have been able to see who last acquired the semaphore.
Can you attach your code?
08-01-2009 01:40 PM
I said that my pictures were taken when I were turning the high light function. If you click zoom on the picture, you will see those waiting green arrows at my acquire semaphore VIs. You cannot see this if I didn't turn on the highlight function.
I can manage to make it run without using the semaphore at asynchronous send-response VIs, but it's not a good way to implement a shraring resource function.
Best regards,
08-01-2009 02:21 PM
I suspect you're running and THEN turning highlighting on, which by then is too late to see what part of your code caused the problem. I would suggest you turn on highlighting before you start running. Then you should be able to step through your code and find where the issue is.
08-03-2009 03:48 PM
Hi Thang,
Will you be able to post a simplified version of your code that reproduces the issue. Also, which version of LabVIEW are you using and what OS? Thank you
08-03-2009 04:01 PM
Hello,
You mentioned that it will run fine 5 or 6 times at first, does this happen every time before it hangs? Does the code hang in deadlock on every trial? Could you maybe post the code as well?
Thanks,
Anna K.