Shared memory sync/update question

T.J. Crowder tj.crowder at farsightsoftware.com
Sat Sep 22 21:28:41 UTC 2018


Can anyone on the list help me with the shared memory details question
described here:
[Does `postMessage` or yielding to the event loop or similar sync shared
memory?][1]

It seems like Lars T. Hansen's Mandlebrot example [here][2] also expects
memory to have been synchronized/updated as of the receipt of a
`postMessage` message (when a worker is done, it triggers a `workerDone`
message making the main thread redisplay), but there's an `Atomics.store`
involved there.

Just trying to get a clear idea of when (and whether) one can reliably,
in-specification trust that a thread will see updates from other threads
without using `Atomics.load` or similar to do every single read. Hansen's
Mandlebrot example uses a lock on a single element via `compareExchange`.
My experiment that never sees a stale read doesn't use `Atomics` at all
(but see the first link above for details).

Thanks in advance,

-- T.J. Crowder

[1]:
https://stackoverflow.com/questions/52445807/does-postmessage-or-yielding-to-the-event-loop-or-similar-sync-shared-memory

[2]:
https://hacks.mozilla.org/2016/05/a-taste-of-javascripts-new-parallel-primitives/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180922/e8c3d79d/attachment.html>


More information about the es-discuss mailing list