キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Program hangs when stopping consumer loop

解決済み
解決策を見る

Hello, I made program that uses occurrences, it's similar to example provided with LabVIEW, but I don't know why it's hanging when I trying to stop consumer loop. The True value is passed by Global Variable and than nothing is happening.
What am I doing wrong?
I know that occurrencies and variables are not best for such purpose, but I have to make some program with them because I'm preparing some workshop to my friends about synchronization pallete.

I'm using LabVIEW 2016 32bit.

Thanks for any clues 😉

すべてをダウンロード
0 件の賞賛
メッセージ1/13
5,205件の閲覧回数

In your consumer loop you are waiting on an occurance, that is never going to happen because you havent wired anything to it.  Remove that occurance and i the application will work.



-Matt
0 件の賞賛
メッセージ2/13
5,185件の閲覧回数

This architecture is too weird to be coded correctly.  I don't think this is a good way to teach someone how to use an occurence.

 

Maybe you could explain what you're trying to show them in more detail and we can come up with something.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 件の賞賛
メッセージ3/13
5,183件の閲覧回数

Well I was asked for whole pallete so I'm doing that 😉 What I wanted? simple occurence counter as in example

I did as they wrote in Simple Occurence Example:

"Stopping the Two Loops:

The Loop Stop global variable is initialized before Loop 1 and Loop 2 start. Then, when the user clicks the Stop button, the top loop stops, sets the Loop Stop global variable to TRUE, and sets the occurrence. This causes Loop 2 to wake up, read the TRUE value of the Loop Stop global variable, and stop executing."

0 件の賞賛
メッセージ4/13
5,179件の閲覧回数

But the application works, and the consumer loop are receiving concurrences from producer loop so it's executing smoothly. Problem occurs when I'm trying to stop that app -  it hangs on consumer loop.

0 件の賞賛
メッセージ5/13
5,176件の閲覧回数

Remove the occurance in the consumer loop.



-Matt
0 件の賞賛
メッセージ6/13
5,174件の閲覧回数

Consumer loop is triggered by Occurrence so I can't remove it

0 件の賞賛
メッセージ7/13
5,170件の閲覧回数

I see the problem here.  What happens is when you push the stop button, the consumer loop has already operated and has read false from the global variable, so when you set the occurance, the consumer loop iterates and reads false from the global variable.

 

The loop reads the true the second time, but is waiting on the occurance to happen again.



-Matt
メッセージ8/13
5,164件の閲覧回数
解決策
トピック作成者nightwisshが受理

You have a race condition.  So when you set the global to TRUE, the global in the consumer has already been read.  But the loop will not iterate until you generate an occurance.  So now the global has been read as a TRUE, but the loop is sitting ther waiting for yet another occurance.

 

In general, I find Occurances to be near worthless.  The only place I have found them useful was in an FPGA project.  What you should be doing here is use a Queue.  What you can do with the queue is add data telling the consumer what to do: Increment Count, Reset, Stop.  Do a good search for Queued Message Handler.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
メッセージ9/13
5,162件の閲覧回数

Ok thank you for explanation Crossrulz 😉 I managed to do some workaround by adding flat sequence in Consumer loop as you can see in code.

Weird. Occurrences never again 😛

 

occurence-sample.png

0 件の賞賛
メッセージ10/13
5,158件の閲覧回数