DEFINITION MODULE Coroutines;
(*
 * 2.0 / 9.6.87 / ms /
 * Coroutines as supported by SYSTEM (PIM Ed. 3)
 *)
(*$ NameChk:=FALSE LargeVars:=FALSE *)

FROM SYSTEM IMPORT
 ADDRESS;

TYPE
 PROCESS=ADDRESS;

(*
 * Da innerhalb einer Coroutine Dos Aufrufe möglich sind,
 * muss sichergestellt werden, dass genügend Arbeits-
 * speicher angelegt wird. Für Dos Aufrufe werden bis zu
 * 1500 Byte benötigt. Falls Sie keine Dos Aufrufe in
 * Ihrer Coroutine haben, können Sie diese Variablen auf
 * kleinere Werte setzen. 'coroutinesMinStack' ist die
 * minimale Grösse des Arbeitsspeichers, die bei
 * NEWPROCESS erwartet wird. 'coroutinesSaveStack'
 * reserviert einen Bereich dieser Grösse im Arbeits-
 * speicher für nicht kontrollierbare Aufrufe (z.B. Dos).
 * Sobald mehr als 'size' - 'coroutinesSaveStack' Byte
 * des Arbeitsspeichers in Gebrauch sind, wird das
 * Programm mit einem Stapelüberlauf abgebrochen.
 *)
VAR
 (*$ LongAlign:=TRUE *)
 coroutinesMinStack: LONGINT;   (* = 2000 *)
 coroutinesSaveStack: LONGINT;  (* = 1600 *)

PROCEDURE TRANSFER(VAR source, destination: PROCESS);
PROCEDURE NEWPROCESS(p: PROC; wsp: ADDRESS;
                     size: LONGINT; VAR new: PROCESS);

END Coroutines.
