MIL_ID SystemId, | //in |
MIL_INT64 ObjectType, | //in |
MIL_INT64 ControlFlag, | //in |
MIL_THREAD_FUNCTION_PTR ThreadFctPtr, | //in |
void *UserDataPtr, | //in |
MIL_ID *ThreadEventOrMutexIdPtr | //out |
This function allocates a MIL thread context, event, or mutex.
Threads are function streams, used to ensure sequential execution of operations within the same thread, while allowing simultaneous yet independent execution of operations in other threads. MthrAlloc() can allocate threads using two different methods:
With the first method (M_THREAD), MthrAlloc() creates a MIL thread context for the new thread, and allows you to specify a pointer to a function that will be executed by the thread. When a thread contains a function call whose target processor is an on-board processor that supports multi-threading, MIL automatically creates a corresponding thread on that system's on-board processor. The functions of the Thread module allow you to synchronize threads running on the Host and/or various MIL systems.
With the second method, MthrAlloc() creates a selectable thread (M_SELECTABLE_THREAD). Selectable threads are threads executed on an on-board processor that supports multi-threading but can be controlled from a single corresponding thread on the Host. Use MthrControl() with M_THREAD_SELECT to send MIL functions to be executed by a selectable thread.
For more information on these two types of threads, see the Multi-threading section of Chapter 30: Multi-processing, multi-core, and multi-threading.
A MIL event is a synchronization marker that can signal the completion of a required set of functions in one thread to other threads. MthrAlloc() can allocate MIL events, or map a new MIL event to an existing MIL event.
A mutex is a mutual exclusion object that allows threads to synchronize access to shared resources. Once a mutex is allocated on the specified system, you can lock and unlock critical sections of code. Locking a critical section of code ensures that no two threads can access the same data at the same time. To lock a MIL mutex, you must call MthrControl() with M_LOCK or M_LOCK_TRY immediately preceding the section of code to lock. If you lock a mutex, you must unlock it at the end of the critical section of code using MthrControl() with M_UNLOCK. Once you are finished using the mutex object, free it using MthrFree().
To control or inquire about a MIL thread context, event, or mutex, use the MthrControl() or MthrInquire() function, respectively. To synchronize the execution of threads, use MthrWait().
Specifies the identifier of the system on which to allocate a MIL thread context, event, or mutex.
This parameter should be set to one of the following values:
For specifying the system
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
MIL system identifier |
Specifies the MIL identifier of the required system, previously allocated using MsysAlloc(). |
Specifies the type of object to allocate. This parameter should be set to one of the following values:
See the Parameter associations section for possible values that can be specified.
Specifies the initialization state of the MIL thread context, event, mutex, or the identifier of an existing MIL event. This parameter should be set to one of the following values:
See the Parameter associations section for possible values that can be specified.
Specifies the address of the function that will be executed by the new thread (M_THREAD). For all other objects, this parameter should be set to M_NULL.
The function must include calls to all functions that you consider as being part of one thread, and be declared as follows:
Specifies a pointer to user data that is passed to the UserDataPtr parameter of MthrAlloc().
Specifies the address of user data necessary to execute the FunctionToCall function of the new thread (M_THREAD). For all other objects, this parameter should be set to M_NULL.
The table below lists possible values for the ObjectType and ControlFlag parameters.
For specifying the type of object to
allocate and its initiation state
|
|||||||||||||||||||||||||||||||||||||||
ObjectType |
Description
|
||||||||||||||||||||||||||||||||||||||
ControlFlag | |||||||||||||||||||||||||||||||||||||||
M_EVENT |
Allocates a new MIL synchronization event on the specified system. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_NOT_SIGNALED + |
Initializes the event as not signaled. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_SIGNALED + |
Initializes the event as signaled. (more details...) |
||||||||||||||||||||||||||||||||||||||
MIL event identifier |
Specifies the identifier of the user-allocated MIL event to which to map the new M_EVENT_CREATE event. |
||||||||||||||||||||||||||||||||||||||
M_EVENT_CREATE |
Creates a new MIL synchronization event on the specified system, which maps to the MIL event specified by the ControlFlag parameter and is in the same state. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_NOT_SIGNALED + |
Initializes the event as not signaled. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_SIGNALED + |
Initializes the event as signaled. (more details...) |
||||||||||||||||||||||||||||||||||||||
MIL event identifier |
Specifies the identifier of the user-allocated MIL event to which to map the new M_EVENT_CREATE event. |
||||||||||||||||||||||||||||||||||||||
M_MUTEX |
Allocates a MIL mutex on the specified system. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Specifies the default initialization state. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_SELECTABLE_THREAD |
Allocates a selectable thread on the specified multi-threaded system. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Specifies the default initialization state. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_TRACE_LOG_DISABLE |
Specifies to disable the creation of trace logs on this thread by any external program, such as Matrox Profiler or the MILConfig utility Interactive Troubleshooting. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_THREAD |
Allocates a thread and associates it with a MIL thread context. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Specifies the default initialization state. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_TRACE_LOG_DISABLE |
Specifies to disable the creation of trace logs on this thread by any external program, such as Matrox Profiler or the MILConfig utility Interactive Troubleshooting. (more details...) |
You must add one of the following values to the above-mentioned values to set how the event is reset.
For M_EVENTM_SIGNALED or
M_EVENTM_NOT_SIGNALED INQ
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_AUTO_RESET |
Specifies that the event is reset automatically. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_MANUAL_RESET |
Specifies that the event is reset manually. (more details...) |
Header | Include mil.h. |
Library | Use mil.lib. |
DLL | Requires mil.dll. |