TobiOS
An operating system simulation written in C++20: a kernel boot sequence, an in-memory filesystem, a process table and a shell. The terminal runs that C++, compiled to WebAssembly, inside this tab.
Nothing is sent to a server.
LIVE WASM Every command is executed by the compiled program in your browser. What it does and does not do
What the code does and does not do
- Shell
- Eight commands:
help,exit,ls,cat,ps,mkdir,touch,status. - Filesystem
- A tree of nodes held in memory, with
/home,/tmpand/bincreated at boot. It is lost on reload, and paths are absolute because the shell has nocd. - Processes
- The process manager holds control blocks and a round-robin queue, but it never runs a program. The kernel creates one
initentry and no shell command adds another, sopsalways lists that one process. - Memory
- A 1 MB first-fit allocator is built and initialised at boot. No shell command calls it, so you can see it reported by
statusbut cannot exercise it from here. - Simulation
- This is a user-space program that models OS concepts. It does not boot on hardware or schedule real tasks.
How the web build works
- Same sources.
main.cppand everything undersrc/go through Emscripten'sem++, with no#ifdefs for the web and no JavaScript copy of the commands. - Blocking stdin. The shell loop calls
std::getline(std::cin, ...), which would freeze a browser tab. A small JS library replaces thefd_readsyscall and uses Emscripten's ASYNCIFY to suspend the wasm stack until you press Enter, then resumes it mid-call. - Terminal.
fd_writehands stdout bytes, ANSI colours included, to xterm.js. The page does what a tty driver would: echo, backspace and history. It only ever passes finished lines to the program. - Exit and reboot.
exitruns the real shutdown path. Reboot starts a new wasm instance, so the filesystem starts over.
One source change was needed: src/memory/memory_manager.cpp and src/process/process_manager.cpp were missing the closing brace of their namespace on the default branch, so the live-demo branch adds those two braces.