While the native filesystem API (fopen/fclose/fread) etc works from any
thread, JS filesystem API (at least the current one, not the new wasmfs
one) is designed to run only the main thread.     The native calls are
automatically proxied back to the main thread where they execute the JS
APIs.   If you are making direct calls to the JS API you need to do it from
the main thread.

You can see how/why the syscalls get proxied back to the main thread here:

https://github.com/emscripten-core/emscripten/blob/86640bc46ce5aad96e86d941cdb81d5db984db7f/src/library_syscall.js#L1172-L1185

cheers,
sam

On Tue, Feb 22, 2022 at 11:21 PM 'zhiqiang ren' via emscripten-discuss <
[email protected]> wrote:

>    How can multiple threads access the same wasm data source? For example,
> the main thread writes data (module.fs.readfile ('File ',' footer ')). I
> want to access it through the new wasm instance in the worker thread,
> module1 FS. readFile('file')。
>
>
> <https://fanyi.baidu.com/translate?aldtype=16047&query=%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B9%8B%E9%97%B4%28worker%29%E6%80%8E%E4%B9%88%E8%AE%BF%E9%97%AE%E5%90%8C%E4%B8%80%E4%BB%BD%E6%95%B0%E6%8D%AE%E6%BA%90%EF%BC%8C%E6%AF%94%E5%A6%82%E4%B8%BB%E7%BA%BF%E7%A8%8B%E5%86%99%E5%85%A5%E6%95%B0%E6%8D%AE%EF%BC%8C%E6%88%91%E6%83%B3%E9%80%9A%E8%BF%87%E5%9C%A8worker%E7%BA%BF%E7%A8%8B%EF%BC%8Cnew+wasm+%E5%AE%9E%E4%BE%8B%E5%8E%BB%E8%AE%BF%E9%97%AE%E5%AE%83%E3%80%82&keyfrom=baidu&smartresult=dict&lang=auto2zh#%23%23>
>
> I've seen the proxy mechanism, but it can only be in the same thread, with
> different new wasm instances
>
> module2. FS. mkdir("/fs1");
> module2. FS. mount(module2.PROXYFS, {
> root: "/",
> fs: module1. FS
> }, "/fs1");
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/5751a37a-b69d-4b32-9bba-0b8a976f4848n%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/5751a37a-b69d-4b32-9bba-0b8a976f4848n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28UOfTskTtayapBBCS03qULTD_e8p2Dsd6wHO8NvwPtGQ%40mail.gmail.com.
  • data sharing 'zhiqiang ren' via emscripten-discuss
    • Re: data sharing 'Sam Clegg' via emscripten-discuss

Reply via email to