Multiprocessing and Multithreading
Multiprocessing involves operation of cards by multiple software processes (i.e. programs); multithreading uses multiple execution threads within a single program. Multithreading is a feature of programming environments such as LabVIEW, and can also be managed through the standard Windows API.
Process-safety
The Piplx driver is process-safe.
The mechanisms for opening and closing Pickering cards allow a particular card to be controlled by only one process at any time.
Using the PIPLX_OpenCards mechanism, a process awaiting the release of cards by another process can repetetively call PIPLX_OpenCards: the function will return zero until control can be obtained. Using the PIPLX_OpenSpecifiedCard mechanism, repeated calls to PIPLX_OpenSpecifiedCard return an error until the card becomes available.
Multiprocess operation can be investigated by running two copies of the PILMon terminal monitor program concurrently. If you wish to test the action of the PIPLX_OpenSpecifiedCard mechanism, PILMon must be started from the command-line with the "-n" option specified to prevent it taking control of the cards with PIPLX_OpenCards.
Thread-safety
The Piplx driver is thread-safe.
Execution of a Piplx driver function by one thread simply blocks its execution by other threads or processes. This includes any settling delay periods, ensuring that no unwanted overlaps occur in operation.
Functions PIPLX_OpenCards and PIPLX_OpenSpecifiedCard
Using the PIPLX_OpenCards mechanism, a process takes control of all Pickering cards that are not currently under the control of some other process. PIPLX_OpenSpecifiedCard just takes control of the chosen card. Only one of these mechanisms can be employed at any time; after loading Piplx_w32.dll the first use of one mechanism disables the other. Thus if multiple applications are to access cards they must all employ the same mechanism for opening and closing them.
Function PIPLX_SetMode
The settings made by PIPLX_SetMode are process-specific, i.e. multiple processes can operate with different settings. One mode flag used in PIPLX_SetMode, MODE_REOPEN, affects cross-process behaviour - see below.
Closing and re-opening cards
Normally when cards are opened using PIPLX_OpenCards all the cards are cleared. The reason for this is that there is no facility to read the state of a card's outputs from the card itself, so that when taking control the software driver has no way of discovering the pre-existing state of the card.
The Piplx driver does however provide a mechanism that allows cards to be re-opened by PIPLX_OpenCards with their existing states intact. This permits cards to be opened and set up by one application, then closed and re-opened by a second application with their states undisturbed. Note that this facility is not available when using PIPLX_OpenSpecifiedCard.
The requirements for this mode of operation are:
The application performing the set-up must have called PIPLX_SetMode with the bit MODE_REOPEN set prior to releasing the cards with PIPLX_CloseCards.
The application taking control of the cards must call PIPLX_SetMode with the bit MODE_REOPEN set prior to executing PIPLX_OpenCards.
Piplx_w32.dll must remain loaded between execution of PIPLX_CloseCards by the releasing process and execution of PIPLX_OpenCards by the process taking control.
If these requirements are not met, cards will be cleared as normal by PIPLX_OpenCards.
The process re-opening the cards can of course be the same one that released them. The method employed involves disk access so the operation does take a significant time, which depends to some extent on the number of cards installed.