-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[interpreter] implement atomic.wait and atomic.notify #194
Conversation
I'm somewhat confused, where is the notion of signal coming from? Is that an encoding of the reaction rules from the paper? I would have expected a more direct implementation with administrative instructions wait' and notify', as on paper. And then perhaps auxiliary functions like the following to implement context matching:
(where the returned functions are "plug" function generated on the way to replace the found instruction with new code). Also, the step function as written seems to initiate all reactions eagerly in a meta-level loop, whereas each wait/notify match is a separate step in the paper rules. |
We discussed before that we wanted to shift away from the paper formulation to an axiomatic specification for wait/notify - i.e. emitting actions without blocking that then get resolved consistently in the memory model. These "signals" are intended to try to reflect the actions relevant for wait/notify in that formulation. I guess I could rename the datatype here to "action" to make the correspondance clearer. |
Ah okay, that probably was a long time ago, so I don't recall. :) What would the reduction rules look like? If these signals correspond to actions, why do they become part of the thread representation in the interpreter? |
I think you're right - they shouldn't be part of the The reduction rules will look something like (roughly)
and then in the axiomatic memory model, all the |
Co-authored-by: Andreas Rossberg <rossberg@dfinity.org>
@rossberg apologies that I let this lie for so long, but PTAL |
@rossberg friendly ping |
let ts1', count1 = wake ts1 m addr count in | ||
let ts2', count2 = wake ts2 m addr (Int32.sub count count1) in | ||
ts1' @ [{t' with code = plug_value t'.code (I32 (Int32.add count1 count2))}] @ ts2' | ||
| _ -> ts1 @ [t'] @ ts2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If WaitAction is not distinguished here, why is it actually needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with removing it - I added it to more closely match the paper but since Notify_actions are being dealt with operationally here it doesn't have any direct purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we may want to think about getting the interpreter closer to the spec somehow wrt the actions it emits, and possibly how it uses them. But let's land this for now.
interpreter/exec/eval.ml
Outdated
type suspend_signal = | ||
No_signal | ||
(* memory, cell index, target timestamp *) | ||
| Wait_signal of memory_inst * Memory.address * float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, it should correspond to what we using on paper. Is that a real number?
@rossberg ptal |
also split out relevant tests into a separate file