From ff2e6c647d166fa54769f3c300855ef7f8020668 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 2 Aug 2016 11:26:56 +0200 Subject: score: Fix and simplify thread wait locks There was a subtile race condition in _Thread_queue_Do_extract_locked(). It must first update the thread wait flags and then restore the default thread wait state. In the previous implementation this could lead under rare timing conditions to an ineffective _Thread_Wait_tranquilize() resulting to a corrupt system state. Update #2556. --- cpukit/score/include/rtems/score/thread.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cpukit/score/include/rtems/score/thread.h') diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index d03f0c25e5..44080f3a82 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -326,6 +326,17 @@ typedef struct { * case the thread is enqueued on a thread queue. */ Chain_Control Pending_requests; + + /** + * @brief Tranquilizer gate used by _Thread_Wait_tranquilize(). + * + * This gate is closed by _Thread_Wait_claim(). In case there are no + * pending requests during a _Thread_Wait_restore_default(), then this gate + * is opened immediately, otherwise it is placed on the pending request + * chain and opened by _Thread_Wait_remove_request_locked() as the last + * gate on the chain to signal overall request completion. + */ + Thread_queue_Gate Tranquilizer; } Lock; /** -- cgit v1.2.3