 |
Synchronization
|
In most real-time systems, there is a need to synchronize the execution of tasks to related events. AMX offers a variety of solutions to the problem of task synchronization.
The simplest form of synchronization involves the starting of a task at the appropriate time. One task, operating in response to its stimulus, can decide to start another task to handle some portion of the processing in a concurrent manner. Timer Procedures can be used to start tasks at precise intervals. Interrupt Service Procedures can start tasks to begin processing in response to specific external events.
A task is started by triggering it for execution. It will execute once for each such trigger received.
AMX offers a message synchronization facility offered in few operating systems.
Using the Mailbox or Message Exchange Manager, a task can send a message to another task and wait for that task to receive and process that particular message. The sender does not have to take any special action; AMX handles its suspension and reactivation automatically. The task receiving the message has the option of acknowledging receipt of the message and allowing the sender to resume execution. If this optional acknowledgement is not exercised, AMX automatically reactivates the sending task upon completion of the processing by the receiving task.
Tasks can be synchronized to events using the wait/wake mechanism. A task asks AMX to unconditionally place it into the wait state. The task remains waiting until some other task, Timer Procedure or Interrupt Service Procedure issues a request to AMX to wake the task. There is a one-to-one relationship between the wait and wake requests.
A variation of the wait/wake pair permits the task to limit the time interval which it is prepared to wait for the wake request. In this case, AMX will resume execution of the waiting task if the specified interval expires prior to a request to wake the task.
The task synchronization techniques just described, although simple, have been found to meet the needs of a wide variety of real-time applications.
 |
|
Task Control |
| Function |
Service |
| cjtktrigger |
Start (trigger) a task with no message |
| cjtkend |
End task execution |
| cjtkpriority |
Change task's execution priority |
| cjtkstatus |
Fetch task status |
| |
| cjtkmsgack |
Acknowledge receipt of a message sent by some other task which is waiting for the message to be delivered and processed |
| |
| cjtkwait |
Wait for an event which will be signalled by a cjtkwake request |
| cjtkwaitm |
Wait for an event which will be signalled by a cjtkwake request
Timeout if event fails to occur within a specified time |
| cjtkdelay |
Wait (delay) for a specified interval
Warning if a cjtkwake signal occurs before the delay expires |
| cjtkwake |
Wake a task which is waiting following one of the above calls |
| |
| cjtksuspend |
Unconditionally suspend a task |
| cjtkresume |
Allow a task suspended by cjtksuspend to resume |
| |
| cjtkcreate |
Create a new task |
| cjtkdelete |
Delete a task |
| cjtkterm |
Enable/disable abnormal task termination |
| cjtkstop |
Force a task to stop but allow it to service any outstanding triggers |
| cjtkkill |
Kill a task by forcing it to stop and deleting all outstanding triggers |
| |
Task switching times are provided on separate AMX data sheets for each target processor. |
|
 |
|