The terms synchronous and asynchronous refer to how the NI-VISA functions will behave relative to their calling threads. Running the NI-VISA functions synchronously will prevent other code from executing in the calling thread. In some situations, such as transferring a large amount of data or ensuring the data gets to or from the device as soon as possible, this may be desirable.
At a lower level, the calling thread is locked for a different amount of time depending on whether the interface is synchronous or asynchronous. For write operations, the data must be transferred from the Application Development Environment (ADE) down to the underlying physical resources provided by the computer. For read operations, the data must be transferred from the physical resources of the device to the ADE. Both of these transfers must pass through several layers of memory.
For a write operation the following sequence occurs:
- The calling thread is locked.
- Data associated with the VISA Write function is transferred from the ADE to VISA memory.
- Polling begins to determine when all the data associated with the VISA Write has been transferred out of VISA memory to the underlying driver for the hardware resource.
- The transfer completes.
- The VISA Write function returns.
The same sequence occurs, but in the reverse order, for read operations.
For synchronous operations, the calling thread is unlocked between steps 4 and 5 above. For asynchronous operations, the calling thread is unlocked between steps 2 and 3. To choose between synchronous and asynchronous for your application, you will need to consider the amount of data being written or read and the number of threads available to the application.
If a large amount of data must be transferred in as short amount of time as possible, you should consider performing the operation synchronously because this will devote the calling thread to transferring data to or from the hardware resources. Executing the operation asynchronously will allow the calling thread to access other parts of the application, but it will take longer to determine if the data has been transferred to or from the hardware resources.
If the number of threads available to an application is small relative to the number of parallel processes, running the NI-VISA operations as asynchronous will make the calling thread available sooner to the other portions of the application. Executing the operation synchronously will devote the calling thread to the NI-VISA operation, ensuring that it will complete as soon as possible but at the expense of overall application performance.
To choose between the synchronous and asynchronous functions in LabVIEW, please see the LabVIEW Help links below.