Running code that uses pthread on node

231 views
Skip to first unread message

Varun Kumar

unread,
Sep 2, 2018, 1:16:27 PM9/2/18
to emscripten-discuss
I have written a small C code which spawns a new thread, waits for it and the thread prints a string. I compiled it to a WebAssembly using emscripten with the flags USE_PTHREADS=1 and PTHREAD_POOL_SIZE=2. I could successfully run the compiled WebAssembly in Firefox Nightly after enabling the share memory option. However, I am not able to run it on node 8 or node 10. Some inputs on how to get it working on node will be helpful. Thanks.

Alon Zakai

unread,
Sep 3, 2018, 10:21:17 AM9/3/18
to emscripten-discuss
Our focus has been on threads in browsers, for now. The main issue is that asm.js and wasm threads depend on Web Workers, which don't exist in Node, so we'd need some other kind of solution there, not sure what that would look like.

I'll open a PR to update the docs on this.

On Sun, Sep 2, 2018 at 10:16 AM Varun Kumar <varunh...@gmail.com> wrote:
I have written a small C code which spawns a new thread, waits for it and the thread prints a string. I compiled it to a WebAssembly using emscripten with the flags USE_PTHREADS=1 and PTHREAD_POOL_SIZE=2. I could successfully run the compiled WebAssembly in Firefox Nightly after enabling the share memory option. However, I am not able to run it on node 8 or node 10. Some inputs on how to get it working on node will be helpful. Thanks.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Varun Kumar

unread,
Sep 3, 2018, 1:57:36 PM9/3/18
to emscripten-discuss
Thank you Alon!
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Derek Schuff

unread,
Sep 7, 2018, 4:17:27 PM9/7/18
to emscripte...@googlegroups.com
Node recently got an experimental worker threads API, https://nodejs.org/api/worker_threads.html that seems to have most of what we would need to make pthreads work (SAB support with postMessage etc). So it could probably be made to work, we just haven't looked directly into it ourselves yet.

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages