98
K
A
DAK
AMX Semaphore Manager
#include "amx831cf.h" /* AMX C Interface Header */
static AMXID daccess; /* Data access semaphore id */
static struct {
int dbpar1; /* parameter 1 */
int dbpar2; /* parameter 2 */
:
:
} datavar; /* Data variable */
void cdecl rruser(void) /* Restart Procedure */
{ajsmcre(&daccess, 1, "DACS"); /* Create counting semaphore */
}
void cdecl sttaskA(void) /* Task A */
{/* Wait for access */
if (ajsmwat(daccess, 0, 20) == AEROK) {
datavar.dbpar1 = 1; /* Set parameters */
datavar.dbpar2 = 1;
}
}
void cdecl sttaskB(void) /* Task B */
{/* Wait for access */
if (ajsmwat(daccess, 0, 10) == AEROK) {
datavar.dbpar1 = 2; /* Set parameters */
datavar.dbpar2 = 2;
}
}
void cdecl sttaskC(void) /* Task C */
{/* Wait 100 ticks for access */
if (ajsmwat(daccess, 100, 5) == AEROK) {
datavar.dbpar1 = 3; /* Set parameters */
datavar.dbpar2 = 3;
}
}