From e581ea9218578364e867b4d2f59635f6dd6a4eeb Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2016 15:00:29 +0200 Subject: score: Fix _Thread_queue_Extract_locked() We must update the wait flags under protection of the current thread lock, otherwise a _Thread_Timeout() running on another processor may interfere. --- cpukit/score/src/threadqenqueue.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cpukit') 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; } -- cgit v1.2.3