[rtems commit] score: Critical fix for _Thread_queue_Dequeue()

Sebastian Huber sebh at rtems.org
Fri Sep 19 12:17:19 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 19 14:19:55 2014 +0200

score: Critical fix for _Thread_queue_Dequeue()

Do not return NULL in case we can dequeue the executing thread.  This
bug was introduced with 32506647001a815e3c0daf25757d386104a07184.

---

 cpukit/score/src/threadqdequeue.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cpukit/score/src/threadqdequeue.c b/cpukit/score/src/threadqdequeue.c
index e364aa9..52ba009 100644
--- a/cpukit/score/src/threadqdequeue.c
+++ b/cpukit/score/src/threadqdequeue.c
@@ -54,18 +54,20 @@ Thread_Control *_Thread_queue_Dequeue(
     }
   }
 
-  /*
-   * We did not find a thread to unblock.
-   */
-  if ( !the_thread ) {
+  if ( the_thread == NULL ) {
+    /*
+     * We did not find a thread to unblock in the queue.  Maybe the executing
+     * thread is about to block on this thread queue.
+     */
     sync_state = the_thread_queue->sync_state;
     if ( (sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT) ||
          (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
       the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SATISFIED;
       the_thread = _Thread_Executing;
+    } else {
+      _ISR_Enable( level );
+      return NULL;
     }
-    _ISR_Enable( level );
-    return NULL;
   }
 
   /*



More information about the vc mailing list