Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE TaskGroup = POINTER TO TaskGroupRec; TYPE TaskGroupRec = RECORD (Tasks.TaskGroupRec) END; TYPE Task = POINTER TO TaskRec; TYPE TaskRec = RECORD (Tasks.TaskRec) END;
TYPE DispatchProc = PROCEDURE (tg: TaskGroup; VAR task: Task); TYPE CreateProc = PROCEDURE (tg: TaskGroup; VAR task: Task); TYPE RemoveProc = PROCEDURE (tg: TaskGroup; task: Task); TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD dispatch: DispatchProc; create: CreateProc; remove: RemoveProc; END;
CONST badTask = 0; CONST failureOfWaitFor = 1; CONST errorcodes = 2; TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: SHORTINT; END; VAR errormsg: ARRAY errorcodes OF Events.Message; VAR error: Events.EventType;
PROCEDURE InitGroup(tg: TaskGroup; if: Interface); PROCEDURE StartScheduler(tg: TaskGroup); PROCEDURE AddTask(tg: TaskGroup; cr: Coroutines.Coroutine; VAR task: Tasks.Task); PROCEDURE Ready(task: Task) : BOOLEAN;
InitGroup initializes a new task group and associates it with the given interface if. The interface procedures are expected to meet following specifications:
StartScheduler starts the scheduling algorithm and returns in case of fatal errors or if all tasks which belong to tg are terminated. StartScheduler calls Tasks.WaitFor with the union of all waiting conditions if all tasks are waiting. This causes the current process to be blocked if StartScheduler has been called by the main task. Note that StartScheduler may be called even if the initial task group is empty. In this case, StartScheduler waits for the first task being added by AddTask and starts afterwards the scheduling algorithm.
AddTask creates a new task which represents cr and includes it in the set of tasks which belong to tg. Further, every task is free to call AddTask while StartScheduler is running.
Ready returns TRUE if task is currently not waiting.
Oberon || Library || Module Index || Search Engine || Definition || Module