A process model can call plug-in entry points from multiple threads. The Batch process model and the Parallel process model create a separate thread and execution for each test socket and create a controller thread and execution to coordinate the activity of the socket threads. A process model calls some entry points from both socket and controller threads and other entry points only from socket threads or only from controller threads.

When a process model invokes a plug-in entry point, the model passes a parameter of type NI_ModelThreadType to the plug-in. The parameter includes the IsController and IsTestSocket Boolean subproperties. Plug-ins can use these subproperties to determine the type of model thread that invokes the plug-in. For example, a Begin entry point might perform a general operation when the controller thread invokes the entry point or a socket-specific operation when a socket thread invokes the entry point.

The Sequential process model creates only one thread that coordinates and performs testing, so the Sequential process model always sets the IsController and IsTestSocket subproperties to True.

Plug-in instance properties that update at run time are called run-time variables. A plug-in uses the following subproperties to store run-time variables specific to the plug-in:

  • <NI_ModelPlugin>.PluginSpecific.RuntimeVariables of type <plug-in name>RuntimeVariables
  • <NI_ModelPlugin>.PluginSpecific.RuntimeVariables.PerSocket of type array of <plug-in name>PerSocketRuntimeVariables

The process model sets the PerSocket property array to have one element for each test socket. Therefore, you can add a property to the <plug-in name>PerSocketRuntimeVariables data type to create a run-time variable that has a separate value for each socket thread.

When you use the Batch or Parallel process models to invoke a plug-in, the plug-in executes as a multithreaded sequence because the model invokes plug-in entry points in the controller thread and the socket threads. Therefore, you can access properties of the plug-in instance from multiple threads in parallel. TestStand ensures that read and write operations to TestStand property values and array element values are atomic. However, NI recommends that you use the following strategies to ensure that different threads safely share access to plug-in instance variables:

  • Add run-time variables only to the <plug-in name>RuntimeVariables and <plug-in name>PerSocketRuntimeVariables data types.
  • If a run-time variable must have a unique value for each test socket, add the variable to the <plug-in name>PerSocketRuntimeVariables data type.
  • Use a TestStand lock or other synchronization method to ensure a thread has exclusive access to the plug-in run-time variables when required.