Guardian Programmer's Guide

Table Of Contents
Writing a Command-Interpreter Monitor ($CMON)
Guardian Programmer’s Guide 421922-014
23 - 55
Sample $CMON Program
! There is no priority processor available, use a
! nonpriority-response processor:
BEGIN
NONPRIORITY^CPU := NONPRIORITY^CPU + 1;
IF NONPRIORITY^CPU = (TOP^CPU^NUMBER + 1)
THEN NONPRIORITY^CPU := 0;
PROCESSCREATION^ACCEPT.PROCESSOR :=
NONPRIORITY^CPU;
END;
! Next priority processor found:
IF CPU^LIST[PRIORITY^CPU] = 1 THEN
PROCESSCREATION^ACCEPT.PROCESSOR :=
PRIORITY^CPU;
END
UNTIL (CPU^LIST[PRIORITY^CPU] = 1 OR COUNT = 16);
END
ELSE
BEGIN
DO
BEGIN
COUNT := 0;
NONPRIORITY^CPU := NONPRIORITY^CPU + 1;
IF NONPRIORITY^CPU = (TOP^CPU^NUMBER +1)
THEN NONPRIORITY^CPU := 0;
COUNT := COUNT + 1;
IF COUNT = 16 THEN
! There is no nonpriority processor available, use a
! priority processor:
BEGIN
PRIORITY^CPU := PRIORITY^CPU + 1;
IF PRIORITY^CPU = (TOP^CPU^NUMBER + 1)
THEN PRIORITY^CPU := 0;
PROCESSCREATION^ACCEPT.PROCESSOR :=
PRIORITY^CPU;
END;
! Next nonpriority processor found:
IF CPU^LIST[PRIORITY^CPU] = 1 THEN
PROCESSCREATION^ACCEPT.PROCESSOR :=
NONPRIORITY^CPU;
END
UNTIL (CPU^LIST[NONPRIORITY^CPU] = 0 OR COUNT = 16);
END;