-
Notifications
You must be signed in to change notification settings - Fork 33
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 hints to yield_now
to allow schedulers to deprioritize a yielding thread
#18
Conversation
tests/asynch/pct.rs
Outdated
|
||
asynch::block_on(async move { | ||
while count.load(Ordering::SeqCst) < NUM_TASKS { | ||
asynch::yield_now().await; |
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.
How about adding a variant of this test without the yield, showing that PCT finds the schedule where the test panics because we hit the max_steps limit?
tests/basic/pct.rs
Outdated
.collect::<Vec<_>>(); | ||
|
||
while count.load(Ordering::SeqCst) < NUM_THREADS { | ||
thread::yield_now(); |
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.
Same as above -- add a variant of the test that panics without the yield?
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 -- maybe add tests that show PCT finds the unfair executions?
…ng thread Tasks that implement busy-wait loops or other infinite loops are a fairness issue for schedulers like PCT, which will run a thread indefinitely until it blocks. This change makes both sync and async versions of `yield_now` act as a hint to the scheduler that the current task should be deprioritized. Only the PCT scheduler acts on this hint, by moving the current task to the lowest priority. We could also make the DFS scheduler react to this hint by not allowing it to re-schedule the current task immediately, but that would be unsound.
da10ad3
to
490b8d5
Compare
Good idea, done. |
Tasks that implement busy-wait loops or other infinite loops are a fairness
issue for schedulers like PCT, which will run a thread indefinitely until it
blocks. This change makes both sync and async versions of
yield_now
act asa hint to the scheduler that the current task should be deprioritized. Only
the PCT scheduler acts on this hint, by moving the current task to the lowest
priority. We could also make the DFS scheduler react to this hint by not
allowing it to re-schedule the current task immediately, but that would be
unsound.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.