WebNova: experimental operating system in WebAssembly

WebNova: experimental operating system in WebAssembly

Unfortunately, hobbyist operating system development does not allow running your pet project on lots of physical systems, because all the environments are so different. It would be very time consuming to write drivers for even the most common hardware, and as a hobbyist OS developer, that is not an option.

I have been playing around with the idea to start working exclusively for the Raspberry Pi, but the lack of proper emulation for that platform discourages me to further pursue that goal. There's a minimal Raspberry Pi target implementation for QEmu, but that only covers the bare necessities. It does not allow access to for example, the NIC, or other peripherals.

You've probably heard about the latest hype, WebAssembly. It's basically a bytecode VM that's built into most major browsers these days. It even has a C(++) toolchain called emscripten and provides access to some of the Web APIs, like IndexedDB, the event loop, etc. I was thinking that it might be fun to see if I can write some kind of OS-like software for WebAssembly, and provide an execution environment for user level programs to run in. It would also be nice to have some kind of "syscalls" for the user level programs to be able to call to provide useful common functionalities like a UI, VFS, multitasking/scheduler, etc.

Introducing WebNova

WebNova is basically just that. It's an experimental toy "kernel" that runs on WebAssembly and aims to provide a simple set of functionalities as syscalls, and should allow end users to run WebAssembly programs inside of it. It should have basic cooperative multitasking support,  a VFS, and a custom UI that uses either SDL or OpenGL to render elements to a canvas.

So I've been toying around with it, setting up a toolchain and development environment and such. Currently, it works, it has a simple scheduler that uses the infamous lottery scheduler (I go more in depth on that here) and a simple logger. Currently, I use xterm.js as a terminal emulator for I/O to the screen.

Here you can find a screenshot of it running the multitasking test:

WebNova running a multitasking experiment

Limitations of WebAssembly

Of course, WebAssembly comes with a bunch of limitations (usually because of security considerations). That makes sense. It does limit what you can do as an "operating system" though. It would have been nice to be able to use native sockets, but it looks like WASM only supports WebSockets. Maybe I can write some kind of application that proxies TCP/UDP traffic over WebSockets and let that run somewhere. Then it could host its own server applications, which would be pretty cool (and secure!).

Another limitations is no native file system access, which is also a shame (but makes sense too). A VFS could provide some kind of file system, perhaps I can let users "upload" files to the VFS as well. Emscripten already provides a VFS backed by IndexedDB, but I want to write this myself.

So, stay tuned, I will write a couple of blog posts in the coming weeks (months?) about this pet project. Maybe I will even provide you with a binary that you can run in your own browser :).

Show Comments