rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | //! Stage 19: run the `threads` test program 40 times in a row.
//!
//! It used to hang about once in 40 runs (the "threads_and_futexes flake").
//! Three kernel bugs were behind it, all races between CPUs, so they only
//! showed up now and then:
//!
//! 1. clone() armed CLONE_CHILD_CLEARTID *after* the new thread was already
//! running. A thread that finished quickly exited before that, nobody
//! woke its joiner, and `join` waited forever.
//! 2. A futex call spun on the address-space lock with interrupts off,
//! while the thread holding that lock (munmap of a finished thread's
//! stack) waited for *this* CPU to answer a TLB-shootdown interrupt.
//! Each waited for the other: a deadlock.
//! 3. futex_wait read the futex word before taking the waiter-list lock,
//! so a wake in between could be missed.
//!
//! A watchdog thread fails the test (with a dump of every thread and
//! futex waiter) if no run finishes for 8 seconds, instead of letting the
//! whole test hang until its timeout.
use ;
use PanicInfo;
use ;
use ;
use ;
entry_point!;
/// How many runs have finished.
static PROGRESS: AtomicU64 = new;
const RUNS: u64 = 40;
!
!
|