-
Notifications
You must be signed in to change notification settings - Fork 217
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
Update the enclave dispatcher thread to wait on a condition variable for incoming writes #6863
Open
eddyashton
wants to merge
15
commits into
microsoft:main
from
eddyashton:ringbuffer_with_condition_variable
Open
Update the enclave dispatcher thread to wait on a condition variable for incoming writes #6863
eddyashton
wants to merge
15
commits into
microsoft:main
from
eddyashton:ringbuffer_with_condition_variable
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…hrough to be used by the main enclave thread
…condition_variable
maxtropets
reviewed
Feb 27, 2025
Co-authored-by: Max <[email protected]>
achamayou
approved these changes
Feb 27, 2025
…condition_variable
…shton/CCF into ringbuffer_with_condition_variable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The core loop for the main thread inside the enclave is reading and processing things off of the inbound ringbuffer. On SGX, where we didn't trust shared memory/standard library interaction between host and enclave, we'd implemented a spin-loop with some back-off/sleep heuristics.
This updates that to use
std::condition_variable
. Whenever the host writes something to the ringbuffer, it notifies. The dispatcher loop waits on this condition variable, so only wakes when (and quickly when) work is available.As a safety hedge, and to make sure this dispatcher thread processes other work (
ThreadMessaging
) that could arrive outside of the inbound ringbuffer, add a timeout to the wait.