The mini system, running in this page
IX · The machine · What to try · Its speed · How it is in a page · t-IX, the tiny system
Each program of IX comes in two sizes. The
mini ones, m-IX, are the faithful ones: Plan 9's programs
written again in OCaml. Below, they run on a Raspberry Pi 1 that is
itself one of them: mini-qemu, the emulator, compiled to
JavaScript, boots mini-9pi, Plan 9's kernel in OCaml, from
its SD card, with the shell, the utilities, the window system, the
editors and the games on it. Everything on the board is IX's own
code, compiled for ARM by its own compilers.
This is an early version: it takes some twenty seconds to the shell's prompt, after 16 MB fetched, and the board is a slow one, of ten to twenty million instructions a second. The tiny system's page, t-IX, starts at once.
The board has two ways in, as a real one has. Its serial
line is the text under the screen: just type, wherever the mouse
is, and the keys go there. Its screen has a keyboard and a
mouse: click the screen, and a blue frame says the keys are the
screen's (a click outside it gives them back to the serial line).
The mouse on the screen is the board's, with its three buttons; its
cursor is your browser's, in the shape the kernel gives it. The
kernel prints its boot on both, then the shell's prompt,
%.
ls /progs, ls /progs/games — the programs of the card, by kind; ls /bin has them all.ps, free, cat /dev/swap — the processes and the memory; ls /lib /src /usr/pad.echo hello | tr a-z A-Z, seq 10 | sort -r, hoc, awk, grep, sed: the shell is mini-rc, Plan 9's rc.rio, typed with the screen clicked — the window system. The right button gives its menu: New, then sweep a rectangle with the right button held, and a shell runs in the window.cameltry, tetris, wolfenstein, typed in a window — the games: the arrows, the space.emacs /src/hello.ml, office, page /lib/pdf/shapes.pdf, drscheme — in a window or on the bare screen. They take a few seconds to start: the card is read as a Pi reads one.The line under the text says two numbers. The first is the ARM instructions the board ran in the last second: under a million when it waits, ten to twenty when a game runs; a real Pi 1 runs some hundreds. The second is the board's clock against yours. The board counts its time in instructions, and the page sets how many make a second by what your browser is measured to run: the clock then keeps yours, and a faster browser is a faster board. What is written to the card is kept in memory, and lost with the page.
Three things make it fast enough to use, each apart from the simple emulator, which is still what runs in a terminal:
Jit.ml:
700 lines). The interpreter runs everything else, and checks the
translation: both can be run on the same block and compared.
After this page's address, to see what each is worth (several with
& between them):
?jit=0 — no translation: every instruction by the interpreter;?draw=kernel — the kernel composes its pixels itself;?input=usb — a USB keyboard and mouse on the board, as a Pi has, and the kernel's own cursor;?run=frames — the board run only inside the browser's frames; ?screen=whole — the whole screen drawn each time;?ips=6 — the board's pace fixed, 6 instructions to its microsecond, whatever the browser can do.
MiniQemuWeb.ml's
first comment has them all.
machine/ — the ARM processor: its instructions decoded and run, its memory, its MMU;raspberry/ — the Pi's board around it: the interrupt controller, the timer, the serial lines, the SD card's controller, the framebuffer, the USB controller with a hub, a keyboard and a mouse;MiniQemuWeb.ml — this page's part: the framebuffer on a canvas, the keys, the mouse, a slice of instructions at each frame. In a terminal the same board is mini-qemu, with QEMU's command line.
js_of_ocaml compiles
them to 200 KB of JavaScript. The page fetches that, the kernel's
image (2.3 MB compressed) and the card's (13 MB compressed, 128 MB on
the board): no server runs anything. On the board,
mini-9pi is
the kernel, and the card's programs are IX's
(the README has them
all, a line each).
From a checkout, ./mini-pi -g mini-9pi runs the same
kernel and card under mini-qemu in a window of your own machine, far
faster, and ./mini-pi -g -q mini-9pi under QEMU.