| Customize Help

Master/slave dynamics on a remote system



When you allocate your function context in the master function (MfuncAlloc()), you must provide an opcode for the slave function. If the slave function will be executed on the master computer, you must provide a pointer to the function using MfuncAlloc() with SlaveFunctionPtr, but if your slave function will be executed by the remote system in a Distributed MIL application you must provide the name of the library file and the name of the function within the library file using MfuncAlloc() with SlaveFunctionDLLName and SlaveFunctionName, respectively. You must also specify, using the InitFlag parameter, if the slave function must be run on the master computer (M_LOCAL) or, when possible, on the remote computer (M_REMOTE). MfuncCall() uses the pointer to call the slave function when it is to be executed on the master computer, and uses either the opcode or the library file to call the slave function when it is to be executed on the remote computer. Even if the slave function will be executed on the master computer, the opcode is still required for error reporting purposes.

For more information about Distributed MIL and its applications, see Chapter 48: Distributed MIL.

Compilation

Depending on the scope requirements of your user-defined function, its master function and its slave function will need to be compiled differently, according to how they will be called and how you want them to be executed. Every user-defined MIL function will have different scope requirements depending on the application in which it is being used. There are 5 possible execution scenarios for a user-defined MIL function:

  • The user-defined MIL function will be called and executed by the Host.

  • The user-defined MIL function will be called by the Host and executed by the remote system.

    In this scenario, the master function should be compiled for the Host and the slave function should be compiled for the slave processor or into a library file, depending on the type of remote system executing the slave function.

  • The user-defined MIL function will be called and executed by the remote system.

    In this scenario, the master and slave functions should be compiled for the slave processor or into a library file, depending on the type of remote system executing the slave function.

  • The user-defined MIL function might be called from either the Host or remote system, and is executed by the remote system.

    In this scenario, the master function should be compiled for both the Host and remote system, and the slave function should be compiled for the slave processor or into a library file, depending on the type of remote system executing the slave function.

The recommended way to compile the master and slave functions of a user-defined MIL function is to compile both master and slave functions for both the Host and remote systems. Compiling the function in this way ensures that your MIL application will be portable to computers that might or might not have access to remote systems. Function contexts allocated to run on the remote computer (MfuncAlloc() with InitFlag set to M_REMOTE) will, in the absence of a remote processor, be executed on the master computer and function contexts allocated using the default execution type (MfuncAlloc() with InitFlag set to M_DEFAULT) will make use of the remote system when one is available.

Compiling a master and/or slave function for the Host processor is typically the same as compiling any other function of your application.

Executing the slave function on a remote system

Typically, MIL automatically determines whether to have the slave function executed by the Host processor or by the remote processor. To determine where to execute the slave function, MIL looks to the values of the user-defined MIL function parameters, registered in the master function. When all of the MIL objects passed as parameters to the function are allocated on the same system, or if one of the parameters is a MIL system identifier, the slave function is executed by the processor associated with that system. If the master function has multiple MIL object parameters, and the MIL objects passed to these parameters are allocated on different systems, an error message is returned.

When a user-defined MIL function has a user-defined MIL object as one of its parameters, and you want the slave function to be executed by a remote processor, you must allocate this object on the system with the remote processor. For more information, see the Associating a MIL identifier with a user-defined object section later in this chapter.

Note that when the slave function is executed by the remote processor, operations that use other systems cannot be executed. For example, when a slave function is executed on a remote system using a Matrox Radient, and there is a call in the slave function to an MdigGrab() function that performs a grab on Matrox Morphis, this grab operation will cause an error.

Using a Library file in a Distributed MIL cluster

When compiling a new user-defined MIL function for a remote system in a Distributed MIL cluster, you must compile your user-defined function into a library file.

In the master function, located in your application running on the Host-type system, you must provide the name of the library file containing the slave function and the name of the slave function, using MfuncAlloc() with SlaveFunctionDLLName and SlaveFunctionName, respectively.

If your function will be called from a remote computer, the library file should also contain the master function of your user-defined function. In the master function, located in the library file, you can provide a pointer to your slave function using MfuncAlloc() using SlaveFunctionPtr, or provide the name of the library file and the name of the slave function, as above. From within the library file, it is faster to provide a pointer to the slave function than it is to provide the name of the library file and the name of the function.