Skip to content

Commit 7453d7e

Browse files
committed
decreasw yield count a bit and explain reasoning a bit more
1 parent b3dd240 commit 7453d7e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/eval.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::*;
2727
/// When the main thread would exit, we will yield to any other thread that is ready to execute.
2828
/// But we must only do that a finite number of times, or a background thread running `loop {}`
2929
/// will hang the program.
30-
const MAIN_THREAD_YIELDS_AT_SHUTDOWN: u32 = 1_000;
30+
const MAIN_THREAD_YIELDS_AT_SHUTDOWN: u32 = 256;
3131

3232
#[derive(Copy, Clone, Debug, PartialEq)]
3333
pub enum AlignmentCheck {
@@ -208,8 +208,12 @@ impl MainThreadState {
208208
// Give background threads a chance to finish by yielding the main thread a
209209
// couple of times -- but only if we would also preempt threads randomly.
210210
if this.machine.preemption_rate > 0.0 {
211+
// There is a non-zero chance they will yield back to us often enough to
212+
// make Miri terminate eventually.
211213
*self = Yield { remaining: MAIN_THREAD_YIELDS_AT_SHUTDOWN };
212214
} else {
215+
// The other threads did not get preempted, so no need to yield back to
216+
// them.
213217
*self = Done;
214218
}
215219
}

0 commit comments

Comments
 (0)