summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpukit/score/src/threadqenqueue.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 803b5568b3..71e93c292d 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -116,10 +116,10 @@ bool _Thread_queue_Extract_locked(
( *operations->extract )( queue, the_thread );
- _Thread_Wait_set_queue( the_thread, NULL );
- _Thread_Wait_restore_default_operations( the_thread );
- _Thread_Lock_restore_default( the_thread );
-
+ /*
+ * We must update the wait flags under protection of the current thread lock,
+ * otherwise a _Thread_Timeout() running on another processor may interfere.
+ */
success = _Thread_Wait_flags_try_change_critical(
the_thread,
THREAD_QUEUE_INTEND_TO_BLOCK,
@@ -133,6 +133,10 @@ bool _Thread_queue_Extract_locked(
unblock = true;
}
+ _Thread_Wait_set_queue( the_thread, NULL );
+ _Thread_Wait_restore_default_operations( the_thread );
+ _Thread_Lock_restore_default( the_thread );
+
return unblock;
}