[PATCH 03/45] score: Delete STATES_WAITING_ON_THREAD_QUEUE

Sebastian Huber sebastian.huber at embedded-brains.de
Fri May 15 11:41:03 UTC 2015


Avoid the usage of the current thread state in
_Thread_queue_Extract_with_return_code() since thread queues should not
know anything about thread states.
---
 cpukit/posix/src/psignalunblockthread.c       |  6 +++---
 cpukit/score/include/rtems/score/statesimpl.h | 26 ++------------------------
 cpukit/score/src/threadqenqueue.c             |  5 ++---
 3 files changed, 7 insertions(+), 30 deletions(-)

diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c
index c56c150..1b3db68 100644
--- a/cpukit/posix/src/psignalunblockthread.c
+++ b/cpukit/posix/src/psignalunblockthread.c
@@ -114,11 +114,11 @@ bool _POSIX_signals_Unblock_thread(
        *  In pthread_cond_wait, a thread will be blocking on a thread
        *  queue, but is also interruptible by a POSIX signal.
        */
-       if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
-         _Thread_queue_Extract_with_proxy( the_thread );
-       else if ( _States_Is_delaying(the_thread->current_state) ) {
+       if ( _States_Is_delaying(the_thread->current_state) ) {
           (void) _Watchdog_Remove( &the_thread->Timer );
           _Thread_Unblock( the_thread );
+       } else {
+         _Thread_queue_Extract_with_proxy( the_thread );
        }
     }
   }
diff --git a/cpukit/score/include/rtems/score/statesimpl.h b/cpukit/score/include/rtems/score/statesimpl.h
index 9f94675..d1c402e 100644
--- a/cpukit/score/include/rtems/score/statesimpl.h
+++ b/cpukit/score/include/rtems/score/statesimpl.h
@@ -105,19 +105,14 @@ extern "C" {
                                  STATES_WAITING_FOR_BSD_WAKEUP         | \
                                  STATES_WAITING_FOR_RWLOCK             )
 
-/** This macro corresponds to a task waiting which is blocked on
- *  a thread queue. */
-#define STATES_WAITING_ON_THREAD_QUEUE \
-                               ( STATES_LOCALLY_BLOCKED         | \
-                                 STATES_WAITING_FOR_RPC_REPLY   )
-
 /** This macro corresponds to a task waiting which is blocked. */
 #define STATES_BLOCKED         ( STATES_DELAYING                | \
+                                 STATES_LOCALLY_BLOCKED         | \
                                  STATES_WAITING_FOR_TIME        | \
                                  STATES_WAITING_FOR_PERIOD      | \
                                  STATES_WAITING_FOR_EVENT       | \
+                                 STATES_WAITING_FOR_RPC_REPLY   | \
                                  STATES_WAITING_FOR_SYSTEM_EVENT | \
-                                 STATES_WAITING_ON_THREAD_QUEUE | \
                                  STATES_INTERRUPTIBLE_BY_SIGNAL )
 
 /** All state bits set to one (provided for _Thread_Ready()) */
@@ -416,23 +411,6 @@ RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked (
 
 /**
  * This function returns true if one of the states which indicates
- * that a task is blocked waiting for a local resource is set in
- * the_states, and false otherwise.
- *
- * @param[in] the_states is the task state set to test
- *
- * @return This method returns true if the state indicates that the
- *         assocated thread is waiting on a thread queue.
- */
-RTEMS_INLINE_ROUTINE bool _States_Is_waiting_on_thread_queue (
-  States_Control the_states
-)
-{
-   return (the_states & STATES_WAITING_ON_THREAD_QUEUE);
-}
-
-/**
- * This function returns true if one of the states which indicates
  * that a task is blocked is set in the_states, and false otherwise.
  *
  * @param[in] the_states is the task state set to test
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 0e16f59..5f94ec9 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -194,13 +194,12 @@ void _Thread_queue_Extract_with_return_code(
 
   _Thread_queue_Acquire( &lock_context );
 
-  if ( !_States_Is_waiting_on_thread_queue( the_thread->current_state ) ) {
+  the_thread_queue = the_thread->Wait.queue;
+  if ( the_thread_queue == NULL ) {
     _Thread_queue_Release( &lock_context );
     return;
   }
 
-  the_thread_queue = the_thread->Wait.queue;
-
   if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_FIFO ) {
     _Chain_Extract_unprotected( &the_thread->Object.Node );
   } else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
-- 
1.8.4.5




More information about the devel mailing list