Skip to content

Commit

Permalink
comment tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 12, 2024
1 parent c41d5b1 commit fe4d327
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/tools/miri/src/concurrency/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct Mutex {
lock_count: usize,
/// The queue of threads waiting for this mutex.
queue: VecDeque<ThreadId>,
/// Data race handle, this tracks the happens-before
/// Data race handle. This tracks the happens-before
/// relationship between each mutex access. It is
/// released to during unlock and acquired from during
/// locking, and therefore stores the clock of the last
Expand All @@ -92,7 +92,7 @@ struct RwLock {
writer_queue: VecDeque<ThreadId>,
/// The queue of reader threads waiting for this lock.
reader_queue: VecDeque<ThreadId>,
/// Data race handle for writers, tracks the happens-before
/// Data race handle for writers. Tracks the happens-before
/// ordering between each write access to a rwlock and is updated
/// after a sequence of concurrent readers to track the happens-
/// before ordering between the set of previous readers and
Expand All @@ -101,7 +101,7 @@ struct RwLock {
/// lock or the joined clock of the set of last threads to release
/// shared reader locks.
data_race: VClock,
/// Data race handle for readers, this is temporary storage
/// Data race handle for readers. This is temporary storage
/// for the combined happens-before ordering for between all
/// concurrent readers and the next writer, and the value
/// is stored to the main data_race variable once all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use std::intrinsics::mir::*;
use std::num::NonZeroI32;

// We define our own option type so that we can control the varian indices.
// We define our own option type so that we can control the variant indices.
#[allow(unused)]
enum Option<T> {
None,
Some(T),
None, // variant 0
Some(T), // variant 1
}
use Option::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn test_timed_wait_timeout(clock_id: i32) {
let mut now_mu: MaybeUninit<libc::timespec> = MaybeUninit::uninit();
assert_eq!(libc::clock_gettime(clock_id, now_mu.as_mut_ptr()), 0);
let now = now_mu.assume_init();
// Waiting for a second... mostly because waiting less requires mich more tricky arithmetic.
// Waiting for a second... mostly because waiting less requires much more tricky arithmetic.
// FIXME: wait less.
let timeout = libc::timespec { tv_sec: now.tv_sec + 1, tv_nsec: now.tv_nsec };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_timed_wait_timeout(clock_id: i32) {
let mut now_mu: MaybeUninit<libc::timespec> = MaybeUninit::uninit();
assert_eq!(libc::clock_gettime(clock_id, now_mu.as_mut_ptr()), 0);
let now = now_mu.assume_init();
// Waiting for a second... mostly because waiting less requires mich more tricky arithmetic.
// Waiting for a second... mostly because waiting less requires much more tricky arithmetic.
// FIXME: wait less.
let timeout = libc::timespec { tv_sec: now.tv_sec + 1, tv_nsec: now.tv_nsec };

Expand Down
5 changes: 2 additions & 3 deletions src/tools/miri/tests/pass-dep/shims/pthread-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ fn test_mutex_libc_static_initializer_recursive() {
}
}

// Testing the behavior of std::sync::RwLock does not fully exercise the pthread rwlock shims, we
// need to go a layer deeper and test the behavior of the libc functions, because
// std::sys::unix::rwlock::RWLock itself keeps track of write_locked and num_readers.
// std::sync::RwLock does not even used pthread_rwlock any more.
// Do some smoke testing of the API surface.
fn test_rwlock_libc_static_initializer() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
unsafe {
Expand Down

0 comments on commit fe4d327

Please sign in to comment.