The Daily CLAD

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

Re: Notification Sender and Reciever

SercoSteveB
Active Participant

What is the value of Numeric Value Out following execution of the VI?

 

Notification Sender and Reciever.png

 

a) 0

b) 1

c) 2

d) Undefined (the VI does not stop)

Comments
crossrulz
Knight of NI

C


GCentral
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
MrStevenUND
Member

C

ersmt444
Member

C most probably

Need some explanations.. from MrStevenUND

MrStevenUND
Member

Follow the chain.  Both loops are going to stop after one itteration.  Everything is using the same notifier refnum.  Since the timeouts are -1, they will wait indefinately until they recieve the notification.

 

Top loop will wait until it recieves the notification from the bottom loop. Once it recieves the notification, it increments and send it back to the bottom loop, which is now waiting.

SabariSaravanan.M
Member

crossrulz
Knight of NI

Just ran it for the first time.  Highlight execution shows what is happening.

 

Key thought: Notifiers are broadcast.  So all reads will get the latest value.  Therefore we hae a race condition and the bottom read will most likely get the 0 that was written by the bottom loop.  But this is a race condition and there is a chance that the bottom loop will "freeze" long enough for the top loop to send the notification and overwrite the first sent notification.

 

So you could get B or C.


GCentral
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
MrStevenUND
Member

Crossrulz beat me to it. I had pulled up the page but got distracted here at work before I could respond.  Yes, there is a race condition.  B or C.

 

Not sure if everyone knows, as I just found out recently - all the screenshots Steve posts are VI Snippets, as shown by the icons in the upper left of the diagram.  You create them by going Edit-Create VI Snippet from Selection.  The main advantage to this is you can click and drag this to your blank VI block diagram and it will create everything in the picture.  Awesome feature to save time and make sure it is correct when trying to understand these questions.

ersmt444
Member

BadreArras

The loop will stop because Random Number can generate random numbers between 0 to 1

ersmt444
Member
What value will be displayed in the Output indicator when the VI completes execution?
 

CLAD.png

a. 5
 
b. 7
 
c. 12
 
d. Indeterminant
 
SabariSaravanan.M
Member

   Hi ersmt444,

Ans: D                   

BadreArras
Member

Hi ersmt444, i get the same question you posted in the clad, my answer was D

SercoSteveB
Active Participant

Answer: B and/or C.   Thanks crossrulz.  Nice comment about VI Snippets MrStevenUND.  I know there is a post waaay back in the blog where I mention that most of the posts are snippets but its probably 3 years old by now.

 

I had answer B in mind when writing the question. 

ChristineM
Member

When the bottom loop Send Notification function sends a notification, is that notification only used once or could both Wait on Notification functions receive the same send notification?  For some reason I thought that one Send Notification function would be sent to all the Wait on Notification functions (and can be used more than once), which would only make it B.  Please clarify.

crossrulz
Knight of NI

Both could use it.  But the bottom loop could "freeze" long enough for the top loop to send a new notification before the bottom loop is able to read the previous notification.  In that case, you will get C.  Weird things can happen when you do things in parallel.


GCentral
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