Clone me on GitHub

tIX

The tiny system, running in this page

IX · The machine · What to try · How it is in a page · The tiny programs · m-IX, the mini system

Each program of IX comes in two sizes. The tiny ones, t-IX, are the free variants: one file each, what is left of a program when compatibility is dropped and only its idea is kept. Among them are a machine of our own design, a kernel for it written in ML, a window system and a game. Below, they run: the machine is the OCaml program, compiled to JavaScript; everything on it is the tiny system's own code, compiled by its own compilers.


The machine


The machine needs JavaScript.



Boot another kernel: tiny-kernel (in ML; the screen, the windows) · t6 (in C, with a disk: a step before tiny-kernel). It has no screen: its console is the text.

What to try

Just type, wherever the mouse is: the line shows on the console, the text under the screen, at its blinking cursor, and Enter gives it to the shell. Once a program draws on the screen (the window system, a game), click the screen to type in it: a blue frame says the keys go there, one by one, to the window under the mouse. Click anywhere outside the screen to type on the console again.

And the network. The machine has a wire, drawn under the console, and this page is its other end: each dot that crosses is a packet, and each line under it says one.

What is honest to say: the machine does not speak to Wikipedia. It speaks its own small protocol (IL, which Plan 9 had instead of TCP) to the other end of its wire, and that end, this page, asks Wikipedia as a page may, reduces the picture to the screen's 256 colours and sends it as rows of bytes. Names, TLS, HTTP and a picture's format are the browser's. The machine's part is the wire, the envelope, the connection that loses nothing, and a program that reads a row and draws it: TinyKernelNetwork.ml, which the page runs too, as the wire's other end.

A note on speed. The machine is paced, as a real one is: it runs a fixed number of instructions each second, so that a game plays the same on a fast computer and on a slow one. Compiled to JavaScript, it is not yet fast enough to keep that pace in most browsers. The line under the console says how close yours gets: at 60%, everything works, and tetris falls at 60% of its speed. Making the machine faster is the next thing to do. (A phone has no keys to type with.)

How it is in a page

tiny-machine is 16 registers, one instruction format, two modes, one trap, a timer that counts instructions, pages, a console, a disk, a screen of 640 by 480 bytes and a mouse. It is three files of OCaml:

js_of_ocaml compiles them to about 90 KB of JavaScript. The page fetches that and the kernel's image, 1.9 MB for tiny-kernel with its programs: no server runs anything. On the machine, TinyKernel.ml, TinyWindows.ml and TinyAppTetris.ml are ML compiled by tiny-ml, and its step t6 is C compiled by tiny-c, both for this CPU.

From a checkout, ./tiny-machine -window tiny-kernel runs it in a window of your own machine, and ./tiny-machine -web dir tiny-kernel makes this page's files.

The tiny programs

The others are in tiny/'s README, a line each with its faithful twin and the idea kept: a build system, a shell, an editor, an assembler, a C compiler, an ML compiler, a database, version control, an ARM CPU and a Raspberry Pi. t-IX's manual tells how they fit, and the code map shows them all.


Back to IX