Sussman and Steele | December 22, 1975 | 32 | Implementation of the Interpreter |
specifically intended to signal interrupts. Thus, if we were to add an interrupt character facility to SCHEME similar to that in MacLISP [Moon], the MacLISP interrupt character function would merely set a register like **TICK**
and dismiss; MLOOP
would eventually notice that this register had changed and dispatch to the interrupt handler. All this implies that the "microcode" for the interrupt handlers does not itself contain critical code that must be protected from host language interrupts.
When the scheduler is invoked, if there is another process waiting on the process queue, then the current process is swapped out and put on the end of the queue, and a new process swapped in from the front of the queue. The process stored on the queue consists of an atom which has the current frame and **VAL**
register on its property list. Note that the **TEM**
register is not saved, and so cannot be used to pass information between instructions.
(DEFUN SCHEDULE () (COND (**QUEUE** (SWAPOUTPROCESS) (NCONC **QUEUE** (LIST **PROCESS**)) (SETQ **PROCESS** (CAR **QUEUE**) **QUEUE** (CDR **QUEUE**)) (SWAPINPROCESS))) (SETQ **TICK** NIL) (ALARMCLOCK 'RUNTIME **QUANTUM**)) (DEFUN SWAPOUTPROCESS () ((LAMBDA (**CLINK**) (PUTPROP **PROCESS** (SAVEUP **PC**) 'CLINK) (PUTPROP **PROCESS** **VAL** 'VAL)) **CLINK**)) (DEFUN SWAPINPROCESS () (SETQ **CLINK** (GET **PROCESS** 'CLINK) **VAL** (GET **PROCESS** 'VAL)) (RESTORE))
Primitive operators are LISP functions, i.e. SUBR
s, EXPR
s, and LSUBR
s.
(DEFUN PRIMOP (x) (GETL x '(SUBR EXPR LSUBR)))
SAVEUP
conses a new frame onto the **CLINK**
structure. It saves the values of all important registers. It takes one argument, RETAG
, which is the instruction to return to when the computation is restored.
(DEFUN SAVEUP (RETAG) (SETQ **CLINK** (LIST **EXP** **UNEVLIS** **ENV** **EVLIS** RETAG **CLINK**)))
RESTORE
restores a computation from the CLINK
. The use of TEMP
is a kludge to optimize the compilation of the "microcode".