LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Semaphore get stuck

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

0 Kudos
Message 1 of 12
(4,118 Views)

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).

Message Edited by Bill@NGC on 07-31-2009 11:22 PM
0 Kudos
Message 2 of 12
(4,095 Views)

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

0 Kudos
Message 3 of 12
(4,088 Views)

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?

0 Kudos
Message 4 of 12
(4,086 Views)

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.

0 Kudos
Message 5 of 12
(4,074 Views)

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.

 

debug.png

 

Can you attach your code?

0 Kudos
Message 6 of 12
(4,062 Views)

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,

 

0 Kudos
Message 7 of 12
(4,059 Views)

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.

0 Kudos
Message 8 of 12
(4,053 Views)

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

0 Kudos
Message 9 of 12
(4,008 Views)

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.

National Instruments
0 Kudos
Message 10 of 12
(4,000 Views)