Skip to content

Commit

Permalink
Merge pull request #589 from stlankes/mutex
Browse files Browse the repository at this point in the history
use always powers of two for the number of threads
  • Loading branch information
stlankes authored Jun 5, 2024
2 parents 09c444b + 19d4611 commit 1ef4cdc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/mutex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{hint, thread};
#[cfg(target_os = "hermit")]
use hermit as _;

const NUMBER_OF_ITERATIONS: usize = 100000;
const NUMBER_OF_ITERATIONS: usize = 100000000;

pub struct SpinBarrier {
num_threads: AtomicUsize,
Expand Down Expand Up @@ -89,7 +89,9 @@ fn main() {
let available_parallelism = thread::available_parallelism().unwrap().get();
println!("available_parallelism = {available_parallelism}");

for i in 0..available_parallelism {
mutex_stress_test(i + 1);
let mut i = 1;
while i <= available_parallelism {
mutex_stress_test(i);
i *= 2;
}
}

0 comments on commit 1ef4cdc

Please sign in to comment.