| aMulti_Wait | Index |
Definition:
| int aMulti_Wait( | ); |
Return Value:
Description:
This routine places the process in a wait state until it receives data from another process via its semaphore. 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: