| aMulti_Signal | Index |
Definition:
Parameters:
| proc | - | The ID of the process that is awaiting data via a semaphore. |
| data | - | The data to be sent to the other process via a semaphore. |
Return Value:
Description:
This routine sends data from one process to another via a semaphore. The process that will receive the data must be expecting input via its semaphore. The semaphore mechanism provides a means for synchronizing multiple processes. Semaphores are accessed via ports. The semaphore associated with a particular process is equal to the base address for semaphore ports plus the process ID.
Example:
(TEA file stored in file slot 0)
#include <aMulti.tea>
int main()
{
int n;
aMulti_Spawn(1,3);
n=aMulti_Wait();
aMulti_Signal(3,n);
n=aMulti_Wait();
aMulti_Signal(3,n);
n=aMulti_Wait();
return n;
}
(TEA file stored in file slot 1)
#include <aMulti.tea>
void main(char callingProcID)
{
int n=100;
aMulti_Signal(callingProcID,n);
n=aMulti_Wait()+100;
aMulti_Signal(callingProcID,n);
n=aMulti_Wait()+100;
aMulti_Signal(callingProcID,n);
}
The first program (0) runs the second program (1) as process 3. The two processes take turns passing a value back and forth. The value is increased by 100 on each round-trip. Both processes terminate and the calling process returns the final value of 300.
Related: