Control Features

For more information about the countdown timer and timer interrupts, see the note on timer interrupts.

Procedure add-exit-procedure!

(add-exit-procedure! thunk) => unspecified

add-exit-procedure! adds thunk to the list of procedures that are run when the Scheme process terminates (either by a call to exit or when end-of-file is detected at the interactive prompt). The procedures are run in the opposite order of that in which they were added.

Procedure add-init-procedure!

(add-init-procedure! thunk) => unspecified

add-init-procedure! adds thunk to the list of procedures that are run when the Scheme process is restarted from a dumped heap image. The procedures are run in the order in which they were added.

Procedure call-without-interrupts

(call-without-interrupts thunk) => object

Call thunk, disabling timer interrupts in its dynamic extent. Returns the value(s) returned by the call to thunk.

Procedure decode-error

(decode-error error [port]) => unspecified

Prints a human-readable form of error on the port, or on the current output port if port is not supplied.

The error is a list as obtained by the error handler, as in the following example where the error handler prints the error and then resets the system:

   (error-handler 
     (lambda error
       (decode-error error)
       (reset)))

Procedure disable-interrupts

(disable-interrupts) => ticks-remaining | #f

Disables timer interrupts and returns the number of ticks remaining on the clock before the next interrupt, or #f if interrupts were already disabled.

Procedure enable-interrupts

(enable-interrupts timer-value) => unspecified

Enables timer interrupts and sets the countdown timer to timer-value, which must be a positive fixnum.

Procedure error

(error arg ...) => unspecified

The error procedure applies the currently installed error handler (see error-handler) to arg ....

Parameter error-handler

The value of the error-handler parameter is a procedure of one or more arguments. The first argument is a key that indicates where the error occurred. If the key is an exact integer, then the error occurred in a primitive or system subroutine, and the integer is the system error code; additional arguments are arguments to the primitive that failed. If the key is the empty list, then it should be ignored. Otherwise, it is part of an error message signalled with 'error' (which calls the installed error handler).

The default error handler prints an appropriate error message and then calls reset.

Procedure eval

(eval datum [environment]) => value ...

Eval conforms to the specification in the R5RS but additionally allows a first-class environment to be used in place of the environment-specifier. If no environment or environment-specifier is used, the current interaction environment is used.

Eval just calls the current value of the evaluator parameter on its arguments.

Parameter evaluator

The value of this parameter is a procedure of one or two arguments: an expression to be evaluated and optionally an environment. The eval procedure calls the value of evaluator.

Procedure exit

(exit) => never returns
(exit value) => never returns

exit runs any exit procedures installed by add-exit-procedure! and then terminates the Scheme process. The optional argument is the exit status to return to the parent process. The default exit status is 0.

Parameter keyboard-interrupt-handler

This parameter takes a value that is a procedure of no arguments. The procedure is called whenever a keyboard interrupt is received by the system. In the current system, a keyboard interrupt can be received in a critical section; the keyboard interrupt handler is called with the interrupt enable state unchanged.

If the keyboard interrupt handler returns, the interrupted computation will continue execution.

Parameter load-evaluator

The value of the parameter load-evaluator is a procedure of two arguments. The procedure is called to evaluate an expression loaded from a source file.

Procedure quit

(quit) => unspecified

Quit calls the currently installed quit handler (see quit-handler).

Parameter quit-handler

The value of this parameter is a procedure of no parameters. The initial value of quit-handler is exit, though the read-eval-print loop sets up its own quit handler.

Procedure reset

(reset) => unspecified

Reset calls the currently installed reset handler (see reset-handler).

Parameter reset-handler

The value of the reset-handler parameter is a procedure of an arbitrary number of arguments. The default reset handler terminates the program; the read-eval-print loop installs a new handler that instead returns control to the read-eval-print loop.

Parameter standard-timeslice

The value of this parameter is a positive fixnum that will be used to reinitialize the countdown timer on expiration.

Using the value returned from standard-timeslice rather than some arbitrary integer value allows you to write programs that manipulate the interrupt enable flag without hard-coding timer values into your program. The value returned is normally very large, ensuring minimal interrupt overhead to the program. However, tasking systems will want to change the timeslice value to ensure reasonable task switching behavior; the "best" setting depends on the system on which Larceny is running and can presumably be computed by the tasking system, if desired.

For what it's worth, a setting of 50000 gives OK interrupt behavior on a Sparc-10 system, about 10 interrupts per second. This of course depends on the actual code running.

Parameter timer-interrupt-handler

The value of this parameter is a procedure of no arguments. The procedure is called with interrupts disabled when a timer interrupt is received and the interrupt enable state is "enabled".

Procedure typetag

(typetag object) => fixnum

Returns the typetag of object if object is boxed, and signals an error if it is not boxed.

Typetags are documented elsewhere.

Procedure typetag-set!

(typetag-set! object typetag) => unspecified

Sets the typetag of object to typetag, if object is boxed, and signals an error if it is not boxed.

Typetags are documented elsewhere.


$Id: control.html,v 1.9 2000/09/12 02:46:45 lth Exp $
larceny@ccs.neu.edu