Here comes my proposal for the new stuff in the 0.6 API. Note that it
sometimes doesn't match the CVS tree in which case the proposal is my
last thought. Packages marked with (o) are opened by default.
A few weeks ago, I replaced David Fishers implementation of events;
his code was based on placeholders. The problem in his implementation
was, that the RTS deadlocked, if all threads were waiting for an
interrupt since the RTS only saw the blocked placeholders. Now, the
base event system is a part of the RTS itself and the scheduler checks
if there are any threads, waiting for an interrupt, just as it does
; block, until interrupt occurs:
(wait-interrupt int last-event)
; block until one of the interrupts in set occurs:
; interrupt sets are constructed as in 0.5.2
(wait-interrupt-set int-set last-event)
; Same as above, but return if no pending interrupt exists
; record, returned by wait-interrupt-X
; from 0.5.2
; extensions to get a useful ADT
(interrupt-in-set? int set)
(insert-interrupt int set)
(remove-interrupt int set)
; includes all interrupts
; all interrupts
There is a fundamental problem with the interaction of signal-handlers
and the event system: While it is possible to have both of them
(actually sighandlers is built on top of the event system now) the
default actions for signal handlers will normally just kill the
process. For compatibility with old code, the signal handlers should be
turned on by default. Maybe something like
would come in handy. On the other hand, the signal handler for SIGINT
is very useful as it allows you to stop all threads.
interface as in 0.5.2, but without interrupt/
I'd like to declare select and select! "deprecated" as it doesn't work
well with the thread system. There should be only one select in the
The code in 0.6 is built on top of channels. This was necessary to let the
scheduler call other threads if something blocks.
internet-host-addresses are now represented as byte-vectors. There
exist a few conversion functions:
(number->internet-host-addresse address32) ->bv
(internet-host-address->number bv) -> old representation
(bytes->internet-host-address b4 b3 b2 b1) ->bv
(internet-host-address->-bytes bv) -> (b4 .. b1)
(internet-host-address->dotted-string bv) -> "18.104.22.168"
(dotted-string->internet-host-address string) ->bv
; Simply calls the C library function and returns its return value.
(crypt key salt)
The Scsh system assigns syslog-ids to every call of openlog. The
syslog-id of the last openlog is recored. If syslog-w/id is called
later and the syslog-id of the last open is not the same as the
argument of syslog-w/id, openlog is called with the values of
syslog-id prior the actual syslog call.
; do openlog, return a syslog-id
(openlog ident [option [facility]]) -> syslog-id
; version without syslog-id for the brave.
(syslog message [level [facility]])
; call openlog, if current syslog-id is not the given one
(syslog-w/id syslog-id message-id [level [facility]])
; As syslog is not part of any standard, this is an intersection of
; Linux, FreeBSD, AIX, IRIX, HP-UX and Solaris.
Performs an obscure series of open, close, delete and ln,
ending up in a file named filename.lock.
; I'd like to add further locking strategies, all obeying this interface:
(with-fs-lock filename body) :syntax
Libscsh resembles Scsh as a C-library. It is intended for applications,
that want to use Scheme/Scsh as their scripting language. This is
vital to our fight against guile.
libscsh = scshvm without "main". Call
int s48_main(long heap_size, long stack_size, char *image_name, int argc,
to fire up Scsh out of your own program. By default, s48_main behaves
just like Scsh itself: it will start a REPL. For batch mode, add the
appropriate switches to argv (e.g. "-c", "-s",...).
If you want to add your own C functions to call from Scheme, write
an initialization function as described in external.ps, but instead of
adding this function to EXTERNAL_INITIALIZERS of the Makefile, apply
int s48_add_external_init(void (*init)())
to it. This feature is new in Scsh, Scheme48 doesn't have it. You
have to ensure, that all calls to s48_add_external_init() happen
before you call s48_main.
As the VM uses global variables, it's not possible to start several
Scshs at the same time.
This is a proposal. _Please_ add your comments.