Subject: Re: running lisp without an OS
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 27 Feb 2003 05:22:41 -0600
Newsgroups: comp.lang.lisp
Message-ID: <i5Gdnbc5fcKcaMCjXTWc-g@speakeasy.net>
Christopher Browne  <cbbrowne@acm.org> wrote:
+---------------
| Oops! dan@dan-and-kim.com (Q-less) was seen spray-painting on a wall:
| > I was wondering how a lisp program could be executed on an
| > embedded processor without an OS. ...
| 
| At the bottom level, you need to have code to manage access to five
| main things:
| 
|   1.  Memory
|   2.  Secondary storage (disk and such)
|   3.  CPU (tasking, threading, and such)
|   4.  Graphics hardware
|   5.  Networking
| 
| In effect, you need something of a "layer below Lisp," implementing
| all of these, to the degree required, to support the hardware you want
| to run on.
| 
| Each of these pieces is pretty sizable, in terms of effort.  Forget
| size and efficiency; it is quite likely that a good implementation
| could be quite efficient in all these areas.  
| 
| The /problem/ is that it's a lot of effort.  And unless you do it
| /really/ carefully, you'll get drawn into supporting a limited set of
| hardware that won't be available two years down the road, thus making
| your system a mere curiosity.  
+---------------

Fortunately, all that work has been done for people, at least for
the x86 CPU architecture:

	<URL:http://www.cs.utah.edu/flux/oskit/>
	The OSKit is a framework and a set of 34 component libraries
	oriented to operating systems, together with extensive documentation.
	By providing in a modular way not only most of the infrastructure
	"grunge" needed by an OS, but also many higher-level components,
	the OSKit's goal is to lower the barrier to entry to OS R&D and
	to lower its costs. The OSKit makes it vastly easier to create a
	new OS, port an existing OS to the x86 (or in the future, to other
	architectures supported by the OSkit), or enhance an OS to support
	a wider range of devices, file system formats, executable formats,
	or network services. The OSKit also works well for constructing
	OS-related programs, such as boot loaders or OS-level servers atop
	a microkernel.

	For language researchers and enthusiasts, the OSKit lets them
	concentrate on the real issues raised by using advanced languages
	inside operating systems, such as Java, Lisp, Scheme, or ML---
	instead of spending six months or years groveling inside ugly code
	and hardware. With the recent addition of extensive multithreading
	and sophisticated scheduling support, the OSKit also provides a
	modular platform for embedded applications, as well as a novel
	component-based approach to constructing entire operating systems. 

The PLT Scheme guys used this to get MzScheme to run on "bare" iron:

	<URL:http://www.plt-scheme.org/software/mzscheme/>
        MzScheme is available in kernel form for x86 machines,
        which allows MzScheme to boot without the aid of a separate
        operating system. The MzScheme kernel is based on the OSKit...

Their reorg'd web site makes it a little hard to find, but this link
should still work:

	<URL:http://www.cs.rice.edu/CS/PLT/packages/download/
	     103p1/mzscheme/mzscheme.i386-kernel.tar.gz>

I would suggest looking to see what they did and how you might make use
of their experience to do the same for Common Lisp.

+---------------
| The net result is that it seems more convenient to program a Lisp to
| run atop (Linux|(Free|Net|Open)BSD) + XFree86, thereby taking
| advantage of the fairly lavish efforts going into
| Network/CPU/Graphics/Disk hardware drivers.
+---------------

Or for bare-bones embedded stuff (on x86), OSKit.

If you need more than OSKit provides, then, yes, of course consider
one of Linux or {Free,Net,Open}BSD. While I personally prefer FreeBSD,
NetBSD in particular supports "weird" (non-x86 clone) hardware well.


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607