Envoy Application Programming Manual

Table Of Contents
TINET Multipoint Supervisor Protocol
Envoy Application Programming Manual427159-001
8-37
Steps of Example Program
Example 8-15. Program Code for TINET Multipoint Supervisor (Page 5 of 13)
! This procedure performs the line polling function. It is
! initially (that is, during task startup) called by each
! task after the task writes its tutorial mask. At this
! time, the return address for each task is saved in the
! task’s task control block. However, polling is not
! initiated during startup. Instead, control returns to
! the startup procedure (where the next task is started).
!
! Polling is initiated when this procedure is
! called after all tasks have been started. When a polled
! terminal responds with data, control is returned
! to the corresponding task.
PROC poll^line (id, buffer, count^read) VARIABLE;
INT id, .buffer, .count^read;
BEGIN
INT g = ’G’,
l = ’L’,
s = ’S’;
! This subprocedure is called to return to the task whose
! terminal completed. If the task id = -1, then a return to
! the start^up procedure is made.
SUBPROC return^to^task (id);
INT id;
BEGIN
IF id >= 0 THEN ! return data (without MCW).
BEGIN
! set count read to line count read -2.
g[cnt^addr] := line^cntread - 2;
! move data to task.
g[buf^addr]:=linebuf[1]
FOR (line^cntread-1)/2;
END;
l[stack^p] := return^p; ! set return p into stack
! marker.
l[stack^e] := return^e; ! set return e into stack
! marker.
l[stack^l] := return^l; ! set return l into stack
! marker.
IF id >= 0 THEN CODE (EXIT 7); ! return to task.
CODE (EXIT 4); ! return to start^up.
END;