The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Parallel Loop Execution

SercoSteveB
Active Participant

The following VI has been created as a template for parallel executing loops.  The Global Variable ‘Stop’ is a system wide variable used to stop many VIs (not just the one shown).  Which of the following statements are TRUE regarding the VI?

VI1.bmp

a) It contains a race condition
b) It unecessarily uses a global variable to move data between two parallel executing loops.
c) A wire should be used to transfer data between parallel executing loops.
d) The ‘Stop’ variable should be a Local rather than a Global.

Comments
mini09
Active Participant

I go with ans D, because a local variable is more preferred for the parallel operation of the loops, since i`m not aware of arce conditions i`m not sure about A option.

Note: race condition dettails are requested to me.

ROSEJ
Member

I think d is the right ans.

Anagha.G
Member

i think b is the right answer as

a. its not a race condition

c.data can not be passed through a wire in two parallel executing loops

d. as this variable is used in different vis it may have to be a global

BenoitP.
Member

i go with the pretty roses, ans b.

I don't know which is the best solution between :

- Use only one Global variable to stop several while loops in the same and in other VIs ?

or

- Use a Local variable to stop all while loops present in the same VI and a Global variable to stop all the other while loops in other VIs ?

mini09
Active Participant

what is the block that is used ouside the loop?

BenoitP.
Member
dharmendra
Member

I go with G.Ana... Answer : B

labnoob
Active Participant

A i think...tis a good one

mini09
Active Participant

I`ve now change in my answer al the answer B,C,D are valid for the one since the best one`s are needed i go with C because in later of LabVIEW the data transer between loops was through lacal variable but in ealy versions wire`s are used to connect them (stop terminals). I belive D and C will also be true with its character to the state diagram.

JÞB
Knight of NI

Answer:

None of the above!  I'm gonna rag on you a bit Steve. The question is flawed. G.Ana correctly eliminated A and C for the reasons G gave.

B and D are eliminated because they refer to a Global Variable! Such a construct that does not exist in the example.

That thing there is a Shared Varialble.


"Should be" isn't "Is" -Jay
SercoSteveB
Active Participant

Ha that's hilarious; two bad questions in a row.  Yep, sorry, hands-up, apologies, .  Spot the CLA who doesn't know the difference between a Global and Shared Variables... I am ashamed.

However the question still stands.  B & D can be illiminated (my attempts to confuse you by deliberately using the wrong name for the BD element failed) now its down to a 50-50.

SercoSteveB
Active Participant

Answer: A.  I think this VI contains a race condition (and in anticipation of it not being a popular answer; so do the NI LabVIEW Core 1 course notes ).

Consider the scenario where the initial value for the 'Stop' shared variable (thanks Jeff) is TRUE.  If the variable in the bottom loop is read before the variable in the top loop is written (they are racing here) with the value of the Stop Control (assuming that value is FALSE), then the bottom loop will stop whilst the top one will carry on iterating.  This is unlikely to be the desired functionality.  If the writing loop beats the reading loop (in the race) then the functionality is different (and probably that which the programmer desired).

vipul982
Member

I would go with B. Even though the Global Variable ‘Stop’ is a system wide variable used to stop many VIs, the parallel loops within a same VI would work better if it was a local variable. Just my views, share or correct me if I am wrong.

Thanks

StefanoFacchine
Member

Hi,

thanks  SercoSteveB for the explanation! I always forget that a race condition can be present at the start of the VI, so that one loop reads an "old" value that is contained in the variable location.

ashwinilele
Member

I thought the ans are A B and D

But I read all explanation I clerify my pt and I changed my ans to A