Schemix

I haven't worked on Schemix since late 2003. It was a lot of fun, but these days a much better way to get some kind of Lisp into your OS kernel is Movitz

Schemix is a Scheme system, implemented as a patch to the Linux kernel. It aims to attain R5RS compliance while remaining small, fast and easy to understand.

The intended use of Schemix is for exploration of the Linux kernel and for rapid, interactive prototyping of Linux drivers and other new kernel features. To achieve this, Schemix attempts to make a large subset of the kernel functionality available to Scheme programs. Interactivity is via a character device, /dev/schemix which presents a REPL (Read, Eval, Print Loop) to anyone having access to the device.

Schemix is based on a stripped-down and modified version of TinyScheme. Currently the system can be successfully compiled into a 2.4.x or 2.5.x kernel, which then reads and executes Scheme code from /dev/schemix. Any output is written to /dev/schemix.

The current release of Schemix (0.2.1) can be downloaded from here.

Schemix has a project page, and a mailing list, both of which are hosted on GNU's Savannah website.

The following is a short example of a Schemix session (colour coded to make it easier to read):

$ cat /dev/schemix

$ echo "(+ 1 2 3)" > /dev/schemix
$ cat /dev/schemix
6
$ cat > /dev/schemix
(define foo (kernel-lambda (char*) printk))
(foo "Blah, blah, blah")

$ dmesg | tail -n 1
Blah, blah, blah
$ echo "(make-device foo ((a 1) (b 2)))" > /dev/schemix
$ ls -l /dev/foo
crw------- 1 root root 10, 1 Mar 31 14:09 /dev/foo
$ echo "a" > /dev/foo
$ cat /dev/foo
1
$ echo "a" > /dev/schemix
$ cat /dev/schemix
Error: eval: unbound variable: a
$ echo "(exit)" > /dev/foo
$ ls -l /dev/foo
ls: /dev/foo: No such file or directory
$ echo "(assert-type 'int kernel::nr_threads)" > /dev/schemix
$ echo "(assert-type 'int kernel::max_threads)" > /dev/schemix
$ echo "kernel::nr_threads" > /dev/schemix
$ cat /dev/schemix
42
$ echo "(set! kernel::max_threads 42)" > /dev/schemix # Don't let any more processes start!
$ echo "kernel::modprobe_path" > /dev/schemix
$ cat /dev/schemix
#<MEMORY-REFERENCE #xc02cd020 (256 bytes, unknown type)>
$ echo "(assert-type '(char 256) kernel::modprobe_path)" > /dev/schemix
$ echo "kernel::modprobe_path" > /dev/schemix
$ cat /dev/schemix
"/sbin/modprobe"
$ echo "(help cons)" > /dev/schemix
$ cat /dev/schemix
The cons procedure (cons obj1 obj2) returns a newly allocated pair whose car is obj1 and whose cdr is obj2. The pair is guaranteed to be different (in the sense of eqv? - and hence also eq?) from every existing object.