About TobiOS

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

tobios@wasm: ~ (C++20 → WebAssembly)

loading

Try a command

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, /tmp and /bin created at boot. It is lost on reload, and paths are absolute because the shell has no cd.
Processes
The process manager holds control blocks and a round-robin queue, but it never runs a program. The kernel creates one init entry and no shell command adds another, so ps always 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 status but 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

  1. Same sources. main.cpp and everything under src/ go through Emscripten's em++, with no #ifdefs for the web and no JavaScript copy of the commands.
  2. Blocking stdin. The shell loop calls std::getline(std::cin, ...), which would freeze a browser tab. A small JS library replaces the fd_read syscall and uses Emscripten's ASYNCIFY to suspend the wasm stack until you press Enter, then resumes it mid-call.
  3. Terminal. fd_write hands 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.
  4. Exit and reboot. exit runs 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.