3 ms·
Could one just treat WebAssembly as virtual bare metal, implement a multithreaded OS in WebAssembly and then spawn threads inside that?
by dheera 4y ago
Could one just treat WebAssembly as virtual bare metal, implement a multithreaded OS in WebAssembly and then spawn threads inside that?
- wahern 4y agoThat's basically how the Go WASM runtime works[1], except when calling outside the WASM virtual machine (e.g. invoking a JavaScript function) the entire Go runtime must block. [1] The Go compiler inserts yield calls (preemption opportunities) at various points in the emitted code, such as at function invocations and within loops.
- paulgb 4y agoTechnically you could, but they'd all be run on the same CPU core. You could spawn a Web Workers for each core, in theory, although some browsers will lie about the number of cores.
- Animats 4y ago> Technically you could, but they'd all be run on the same CPU core. Right. The goal for games is to get more CPUs working on the problem.