-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add SelfContainedChannel #2757
Add SelfContainedChannel #2757
Conversation
7b8ff79
to
a08e75b
Compare
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.
I still want to look at this a little more, but figured I might as well leave the comments I have so far.
d5b387d
to
e51a34b
Compare
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.
Looks good to me!
e51a34b
to
2bc0e12
Compare
Thanks for the careful review! |
We're going to need to port additional synchronization primitives suitable for use in shared memory to Rust. I think conceptually it makes sense to put these in a crate together separate from the shared memory allocator, which isn't as closely related.
We'll want to reuse these for additional modules in this crate.
This is a VirtualAddressSpaceIndependent implementation of a channel. The intent is to use this to replace `BinarySpinningSem` and `IPCData` to communicate with managed threads from ManagedThread in Shadow.
The previous implementation had potential undefined behavior due to optimistically updating state without checking the previous state. We do away with the `fetch_add` and `fetch_sub` tricks here (with sanity checks after the fact), and instead use e.g. `compare_exchange`. This results in additional atomic operations in the "happy" path, but is easier to understand, especially in failure cases.
This is more general and more closely aligned with `std::mpsc::channel` terminology.
2bc0e12
to
0f16c48
Compare
We need a vasi (
VirtualAddressSpaceIndependent
) wrapper or reimplementation ofIPCData
(essentially a pair of fixed-size channels) for communication between shadow and the shim before migratingManagedThread
to Rust.This PR:
SelfContainedMutex
into a new crate, where we can putIPCData
and any other vasi sync primitives we end up needing to implement.SelfContainedMutex
SelfContainedChannel
and corresponding loom-compatible tests. It should be simple to replaceIPCData
with a pair of these.