API and ALT i vårt kanal-lag
API funksjoner er pakket i makroer:
#define CHAN_INIT_F (CHAN,SENDER,RECEIVER,ALTTAKEN)
#define CHAN_IN_F (CHAN,DATA,EVENT)
#define CHAN_IN_VARLEN_F (CHAN,LEN,DATA,EVENT)
#define ALT_CHAN_IN_F (GUARD,CHAN,DATA,EVENT,ALTTAKEN)
#define ALT_CHAN_IN_VARLEN_F (GUARD,CHAN,LEN,DATA,EVENT,ALTTAKEN)
#define ALT_CHAN_IN_ASYNC_SIGNAL_F (GUARD,CHAN,EVENT,ALTTAKEN)
#define CHAN_OUT_F (CHAN,DATA,EVENT)
#define CHAN_OUT_VARLEN_F (CHAN,LEN,DATA,EVENT)
#define CHAN_OUT_ASYNC_SIGNAL_F (CHAN,RESCHEDULEME)
#define CHAN_IN_ASYNC_SIGNAL_F (CHAN,EVENT)|
#define ALT_TIMER_IN_F (GUARD,TIME,UNIT,EVENT,ALTSTATE,ALTTAKEN)
#define FSM_RESCHEDULE_F (EVENT)
Eksempel på en ALT:
case ST_STATE_IN_ALT_200_202_204_301_A:
{
// CP er "ContextPtr"
ALT_CHAN_IN_ASYNC_SIGNAL_F (CP->Guard_202i, g_chan_202, S_EVENT_ALT_202_A, &alt_taken);
ALT_CHAN_IN_ASYNC_SIGNAL_F (CP->Guard_204i, g_chan_204, S_EVENT_ALT_204_A, &alt_taken);
ALT_CHAN_IN_F (CP->Guard_200i, g_chan_200, CP->Chan_200i, S_200_A, &alt_taken);
ALT_CHAN_IN_F (CP->Guard_301i, g_chan_301, CP->Chan_301i, S_301__A, &alt_taken);
ALT_TIMER_IN_F (CP->Guard_Tim, CP->Tim, TU_MS_A, S_TIME_A, &g_ALT_LH &alt_taken);
//
CP->State = ST_STATE_IN_ALT_200_202_204_301_END_A;
} break;