You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
The current proposal defines atomics within a single array buffer. It says nothing of ordering when atomic accesses are performed on distinct array buffers: one piece of code could be accessing two separate objects. Consider:
varcount=0;while(true){while(Atomics.load(ia1,42)==0)continue;// Wait on other.console.log("Thread 1: "+count);count++;Atomics.store(ia1,42,0);// Reset self.Atomics.store(ia2,42,1);// Unblock other.}
Thread 2:
varcount=0;while(true){Atomics.store(ia2,42,0);// Reset self.Atomics.store(ia1,42,1);// Unblock other.while(Atomics.load(ia2,42)==0)continue;// Wait on other.console.log("Thread 2: "+count);count++;}
Is this code guaranteed to always print out in locksteps? This sounds like a trivial "yes", but it's not obvious from the current spec that synchronization across distinct array buffers also works. I think this is especially important to spell out if we want a formal model of the JavaScript memory model: C++'s memory model is based on having a single heap.
I got onto this line of thinking because of WebAssembly/design#314, where we discuss having individual non-aliased objects being individually accessible atomically.
The text was updated successfully, but these errors were encountered:
Nice catch. The intent has always been that there is "one memory" even though there may be multiple shared memory regions within it. Will attempt to clarify that when I incorporate the improved wording for the memory model.
The current proposal defines atomics within a single array buffer. It says nothing of ordering when atomic accesses are performed on distinct array buffers: one piece of code could be accessing two separate objects. Consider:
Setup:
Thread 1:
Thread 2:
Is this code guaranteed to always print out in locksteps? This sounds like a trivial "yes", but it's not obvious from the current spec that synchronization across distinct array buffers also works. I think this is especially important to spell out if we want a formal model of the JavaScript memory model: C++'s memory model is based on having a single heap.
I got onto this line of thinking because of WebAssembly/design#314, where we discuss having individual non-aliased objects being individually accessible atomically.
The text was updated successfully, but these errors were encountered: