[rtems commit] score: Fix _Thread_queue_Extract_locked()

Sebastian Huber sebh at rtems.org
Wed Apr 6 08:32:11 UTC 2016


Module:    rtems
Branch:    master
Commit:    e581ea9218578364e867b4d2f59635f6dd6a4eeb
Changeset: http://git.rtems.org/rtems/commit/?id=e581ea9218578364e867b4d2f59635f6dd6a4eeb

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Mar 30 15:00:29 2016 +0200

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(-)

diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 803b556..71e93c2 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;
 }
 




More information about the vc mailing list