logoalt Hacker News

A real Linux kernel, compiled to WebAssembly

20 points • by DonAtimator • last Tuesday at 4:35 PM • 4 comments • view on HN

Comments

d33 • today at 10:46 AM

Awesome! I'd love to see userspace work in wasm too though. Someone once did a PoC, but scheduling processes was a pain - AFAIK noone knows how to force preemption?

https://joelseverin.github.io/linux-wasm/

Waraqa • today at 10:51 AM

If I write any app name, it will automatically start apt-get install that app. Ctrl + C doesn't stop it. Are there different shortcuts?

loftsy • today at 10:46 AM

Seems to me that Replit should be using something like this rather than running your app remotely.

DonHopkins • today at 10:52 AM

Another way to run whole operating systems in the browser is to put a second JIT on top of the browser's: an instruction set emulator that compiles guest code to JavaScript, which V8 then compiles to native code. The JavaScript JIT speculates and inlines based on the code that is actually running, so if you generate JavaScript it can optimize well, it does a lot of the work for you. Vanessa Freudenberg made this argument for the SqueakJS JIT here in 2023: "That would potentially give us more speed than even WASM." (https://news.ycombinator.com/item?id=38774277)

Here is PDP-7 Unix running that way. The emulator's CPU is built on the design of Korz, David Ungar's successor to Self (with Harold Ossher and Doug Kimelman at IBM Research). Self's adaptive compilation is where V8's techniques came from, so the lower JIT is being fed what it was built for:

https://hyperties.org/cabinet/systems/pdp-7-unix/

The same PDP-7 runs Mitch Bradley's PDP-7 Forth, PIXIE from 1971, and Unix, and there's a Korz Apple ][ running Little Computer People.

Forth Day talks, Mitch Bradley on PDP-7 Forth and me on the PDP-7 and Apple ][ emulators:

https://www.youtube.com/watch?v=k2pwJ294r8o

The demo that goes with the talk:

https://www.youtube.com/watch?v=I-Rf3XP_D0g

More about PDP-7 Forth:

https://github.com/SimHacker/WillWrightShowForFood/blob/main...

More about Korz:

https://github.com/SimHacker/moollm/blob/main/designs/korz