trylobite
A small Unix-like operating system for a computer that counts in threes.
trylobite runs on detrytus, a balanced-ternary machine.
It has processes, a filesystem, a shell with pipes and job control, a
network stack, ssh, a vi, and about sixty programs. detrytus doesn't
exist in silicon, so you boot trylobite in the emulator on your own
computer, in a few minutes, with no special hardware and no root access.
The name is trilobite with a tryte in it: an ancient sea creature, living among the detritus.
What you can do with it
- Use a shell.
ls,cat,cd, pipes, redirection, variables, quoting, line editing with history and Tab completion, and job control with Ctrl-Z,jobs,fgandbg. - Run real programs.
grep,sort,find,diff,tar,less,ps,top,kill,df, avieditor, and toys likermandel, which draws the Mandelbrot set. - Keep files. Files live on a disk image, in a copy-on-write filesystem with owners, permissions and timestamps, which a power cut can never leave half written. How it keeps your files explains how.
- Go online.
ping,nc,host, an NTP client that sets the clock, and a web server. The page you are reading came from that web server. - Log in remotely.
sshdworks with ordinary OpenSSH, so you cansshinto the machine from your own terminal. - Use several cores. Up to nine, which can be added and removed while it runs.
Try it
You need rustup (Rust 1.97 or later), Python 3 and
make.
git clone https://github.com/sgaduuw/trylobite
cd trylobite
tools/install-detrytus
make
make run
The first make compiles every program and takes a few minutes. You then
get the boot messages and a $ prompt: try ls, hello | upper, ps,
rmandel or vi notes. exit powers the machine off.
How it works
trylobite is a microkernel. The kernel itself only runs processes, gives each its own memory, passes messages between them and keeps track of their open files. Everything else, even the disk driver and the filesystem, is an ordinary process that other processes send messages to:
┌──▶ fsd (files) ──▶ diskd (disk) ──▶ block device
├──▶ consd (console) ──▶ console
sh ─────┼──▶ piped (pipes)
└──▶ ipd (ARP, ping, UDP, TCP) ──▶ netd (frames) ──▶ network device
Nothing is binary underneath, and a few things look different because of it:
- −1 is an ordinary number, so no system call uses it to mean "failed". Errors are negative numbers with names.
- Flags are trits. Options that Unix combines as bits add up as powers of three instead.
- The kernel lives at negative addresses and programs at positive ones. The nine cores are numbered −4 to +4.
The kernel is partly detrytus assembly and partly Rust, and every program on the disk is Rust, translated from the compiler's intermediate code to detrytus machine code by detrytus's own tools.
Read more
The trylobite repository has the
full documentation: its
README, the kernel and every
system call in
docs/kernel.md,
and the disk format in
docs/filesystem.md.