From ade1111af0e0d253418c0707ad4e15b71a191348 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Aug 2019 16:23:59 +0200 Subject: Implement general deadlock detection via monitoring thread --- libbuild2/scheduler.hxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libbuild2/scheduler.hxx') diff --git a/libbuild2/scheduler.hxx b/libbuild2/scheduler.hxx index 09c9e02..af1deba 100644 --- a/libbuild2/scheduler.hxx +++ b/libbuild2/scheduler.hxx @@ -440,7 +440,18 @@ namespace build2 // We increment it for each active->waiting->ready->active transition // and it is used for deadlock detection (see deactivate()). // - size_t progress_; + // Note that it still serves our purpose even if the value wraps around + // (e.g., on a 32-bit platform). + // + atomic_count progress_; + + // Deadlock detection. + // + std::thread dead_thread_; + std::condition_variable dead_condv_; + + static void* + deadlock_monitor (void*); // Wait queue. // -- cgit v1.1