CLAD Timing, Synchronization & Parallel Execution 2 — Questions and Answers
Question 1: Which LabVIEW synchronization primitive stores every element sent in a FIFO buffer, ensuring no data is lost between parallel loops?
- Notifier
- Global Variable
- Queue (Correct answer)
- Occurrence
Correct answer: Queue
Queues implement a FIFO buffer so every element enqueued is preserved until explicitly dequeued, making them ideal for lossless data transfer between producer and consumer loops.
Question 2: What is the key behavioral difference between a Notifier and a Queue in LabVIEW?
- Notifiers only support Boolean data; Queues support any data type
- A Notifier delivers only the most recent value to all listeners without buffering intermediate values (Correct answer)
- Queues support timeout parameters; Notifiers have no timeout option
- Notifiers are faster than Queues for transferring a single element
Correct answer: A Notifier delivers only the most recent value to all listeners without buffering intermediate values
A Notifier replaces its stored value each time a new one is sent and broadcasts that latest value to all waiting listeners, so intermediate values sent before a listener reads can be lost.
Question 3: In LabVIEW, a Semaphore is primarily used to:
- Transfer data between parallel loops in FIFO order
- Broadcast timing signals to multiple synchronized loops
- Generate periodic timed interrupts within a VI
- Control exclusive access to a shared resource and prevent race conditions (Correct answer)
Correct answer: Control exclusive access to a shared resource and prevent race conditions
Semaphores implement mutual exclusion by allowing only one task at a time to acquire the semaphore, ensuring that critical sections accessing shared resources are not executed concurrently.
Question 4: The 'Rendezvous' synchronization primitive in LabVIEW is designed to:
- Buffer data between producer and consumer loops
- Introduce a precise time delay into a parallel task
- Hold all participating tasks at a common synchronization point until every task arrives (Correct answer)
- Lock a functional global variable for single-writer access
Correct answer: Hold all participating tasks at a common synchronization point until every task arrives
A Rendezvous causes each registered task to block at the Wait on Rendezvous call until all expected tasks have arrived, after which all tasks are released simultaneously.
Question 5: In a Producer-Consumer architecture in LabVIEW, what is the primary role of the Queue connecting the two loops?
- To set the execution priority of the consumer relative to the producer
- To decouple the production rate from the consumption rate by buffering elements (Correct answer)
- To synchronize the exact start time of both loops
- To limit the total number of elements the producer is permitted to generate
Correct answer: To decouple the production rate from the consumption rate by buffering elements
The Queue acts as a buffer between the loops, allowing the producer to enqueue data at its natural rate and the consumer to dequeue and process at a different rate without either loop blocking the other.
Question 6: Which of the following scenarios is most likely to cause a race condition in LabVIEW?
- Using a Queue to pass data from a producer loop to a consumer loop
- Using a Semaphore to guard a shared file handle accessed from two loops
- Reading and writing the same Local Variable from two parallel While Loops (Correct answer)
- Using shift registers to accumulate data within a single While Loop
Correct answer: Reading and writing the same Local Variable from two parallel While Loops
Local Variables in LabVIEW do not provide thread-safety; two parallel loops accessing the same Local Variable can read stale data or overwrite each other's writes, producing unpredictable results.
Question 7: When Dequeue Element is called on an empty Queue with a timeout value of 0 ms, the function will:
- Block indefinitely until an element is enqueued by another loop
- Return the last element that was successfully dequeued
- Automatically destroy the Queue reference
- Return immediately and output a timeout error (Correct answer)
Correct answer: Return immediately and output a timeout error
A timeout of 0 ms instructs Dequeue Element to perform a non-blocking check — if no element is present, it returns at once with a timeout error rather than waiting.
Which LabVIEW synchronization primitive stores every element sent in a FIFO buffer, ensuring no data is lost between parallel loops?