Re:WebAssembly: Docker Without Containers
by jjtheblunt on Wednesday December 21, 2022 @11:49AM
(#34083062)
how does pthread_create compile down?
[ Parent
| on HN ]
Re:WebAssembly: Docker Without Containers
by azakai on Wednesday December 21, 2022 @12:00PM
(#34083226)
In Emscripten that uses a pthread implementation layer built on top of Web Workers + a shared wasm Memory. Basically memory is shared, and you have atomic instructions, and each thread of execution gets its own Web Worker.
That has some limitations, but for the most part it works just like you would expect pthreads to.
Re:WebAssembly: Docker Without Containers
by jjtheblunt on Wednesday December 21, 2022 @03:33PM
(#34086032)
what's the non-most part that differs?
Re:WebAssembly: Docker Without Containers
by azakai on Wednesday December 21, 2022 @03:38PM
(#34086092)
The main thread is a little special on the Web since it can't block, which can cause issues (like pthread_create doesn't immediately create an available pthread). There are workarounds for most of those issues (like pre-allocating a threadpool), and many applications work well, but sometimes not out of the box. See
https://emscripten.org/docs/porting/pthreads.html#special-co...
Re:WebAssembly: Docker Without Containers
by jjtheblunt on Wednesday December 21, 2022 @03:42PM
(#34086132)
thank you