Currently we use a template parameter called InvertInbox to invert the
inbox when we load it. This is more easily understood as a static check
on whether or not the process running it is the server. Inverting the
inbox makes the states 1 0 and 0 1 own the buffer, so it's easier to
simply say that the server own the buffer if in != out. Also clean up some of
the comments.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Different definitions of simple in play here.
If
- one reasons in terms of the values in the underlying memory
- focuses on the differences between client and server
- prefers code duplication
Then this is a reasonable way to go.
The direction I'm trying to take this in is different.
- move atomic ops and fences out of client/server
- concurrency logic in process is the same for either instance
- client/server only work with concepts libc cares about
That has the advantage that the code in process covers all the subtle concurrency hazards and can be tested in isolation, notably stress tested under thread sanitisers with both sides running on x64. It also means the libc send/recv stuff can evolve over time more easily as it doesn't have to worry about breaking the concurrency model.
It also has the advantage that inbox and outbox always mean exactly the same thing, on client or server or process, which I find far easier to reason about than keeping track of which is the root of a given function call.
I'm ok with not thinking about whether a given block of memory underlying a mailbox has particular numbers written into it, in exchange for thinking about the states the machine is in.
Update to make this more obvious that we are simply moving the inversion from
the load to the condition. The inversion affects the condition so it is more
intuitive for the condition itself to be inverted. That is !a == b is the same
as !(a == b).
I'm not convinced. This means reasoning in terms of the values in memory instead of in the abstract state of a process. However the change is localised and easy to reverse if it interacts badly with future patches and you seem to be especially passionate about this.