What is the value of Numeric Value Out following execution of the VI?
d) Undefined (the VI does not stop)
C most probably
Need some explanations.. from crossrulz MrStevenUND
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.
Hi crossrulz & MrStevenUND,
I'm having confusion! Could explain it your ans briefly?
When I was tried it says ans: B
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.
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.
The loop will stop because Random Number can generate random numbers between 0 to 1
Hi ersmt444, i get the same question you posted in the clad, my answer was D
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.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.