[rtems commit] score: Untangle thread actions

Sebastian Huber sebh at rtems.org
Fri Dec 11 07:56:29 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Dec 10 14:10:48 2015 +0100

score: Untangle thread actions

Remove the thread action handler parameter from
_Thread_Action_initialize() and instead set it later in
_Thread_Add_post_switch_action().  This avoids a dependency on the
thread action handler via the thread initialization.

---

 cpukit/posix/src/psignalunblockthread.c       |  6 +++++-
 cpukit/posix/src/pthread.c                    |  6 +-----
 cpukit/rtems/src/signalsend.c                 |  3 ++-
 cpukit/rtems/src/taskmode.c                   |  4 +++-
 cpukit/rtems/src/tasks.c                      |  2 +-
 cpukit/score/include/rtems/score/threadimpl.h | 11 ++++++-----
 cpukit/score/src/threadinitialize.c           |  5 +----
 cpukit/score/src/threadrestart.c              | 15 +++++++++++++--
 8 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c
index fd5c30b..ff5a8fa 100644
--- a/cpukit/posix/src/psignalunblockthread.c
+++ b/cpukit/posix/src/psignalunblockthread.c
@@ -40,7 +40,11 @@ static bool _POSIX_signals_Unblock_thread_done(
   bool               status
 )
 {
-  _Thread_Add_post_switch_action( the_thread, &api->Signal_action );
+  _Thread_Add_post_switch_action(
+    the_thread,
+    &api->Signal_action,
+    _POSIX_signals_Action_handler
+  );
 
   return status;
 }
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index da0cf48..5ba2691 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -229,11 +229,7 @@ static bool _POSIX_Threads_Create_extension(
     api->signals_blocked = SIGNAL_ALL_MASK;
   }
 
-  _Thread_Action_initialize(
-    &api->Signal_action,
-    _POSIX_signals_Action_handler
-  );
-
+  _Thread_Action_initialize( &api->Signal_action );
   _Thread_queue_Initialize( &api->Join_List, THREAD_QUEUE_DISCIPLINE_FIFO );
 
   _Watchdog_Preinitialize( &api->Sporadic_timer );
diff --git a/cpukit/rtems/src/signalsend.c b/cpukit/rtems/src/signalsend.c
index c86c399..4153e40 100644
--- a/cpukit/rtems/src/signalsend.c
+++ b/cpukit/rtems/src/signalsend.c
@@ -49,7 +49,8 @@ rtems_status_code rtems_signal_send(
           _ASR_Post_signals( asr, signal_set, &asr->signals_posted );
           _Thread_Add_post_switch_action(
             the_thread,
-            &api->Signal_action
+            &api->Signal_action,
+            _Signal_Action_handler
           );
         } else {
           _ASR_Post_signals( asr, signal_set, &asr->signals_pending );
diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c
index de30806..fadca68 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -21,6 +21,7 @@
 #include <rtems/rtems/tasks.h>
 #include <rtems/rtems/asrimpl.h>
 #include <rtems/rtems/modesimpl.h>
+#include <rtems/rtems/signalimpl.h>
 #include <rtems/score/schedulerimpl.h>
 #include <rtems/score/threadimpl.h>
 #include <rtems/config.h>
@@ -103,7 +104,8 @@ rtems_status_code rtems_task_mode(
         needs_asr_dispatching = true;
         _Thread_Add_post_switch_action(
           executing,
-          &api->Signal_action
+          &api->Signal_action,
+          _Signal_Action_handler
         );
       }
     }
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index e5a80ee..c4eca04 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -55,7 +55,7 @@ static bool _RTEMS_tasks_Create_extension(
   api = created->API_Extensions[ THREAD_API_RTEMS ];
 
   _ASR_Create( &api->Signal );
-  _Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler );
+  _Thread_Action_initialize( &api->Signal_action );
 #if !defined(RTEMS_SMP)
   created->task_variables = NULL;
 #endif
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index cf32082..c61dd89 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -847,11 +847,9 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize(
 }
 
 RTEMS_INLINE_ROUTINE void _Thread_Action_initialize(
-  Thread_Action         *action,
-  Thread_Action_handler  handler
+  Thread_Action *action
 )
 {
-  action->handler = handler;
   _Chain_Set_off_chain( &action->Node );
 }
 
@@ -890,8 +888,9 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_release_and_ISR_enable(
 }
 
 RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
-  Thread_Control *thread,
-  Thread_Action  *action
+  Thread_Control        *thread,
+  Thread_Action         *action,
+  Thread_Action_handler  handler
 )
 {
   Per_CPU_Control *cpu_of_thread;
@@ -899,6 +898,8 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
 
   cpu_of_thread = _Thread_Action_ISR_disable_and_acquire( thread, &level );
 
+  action->handler = handler;
+
 #if defined(RTEMS_SMP)
   if ( _Per_CPU_Get() == cpu_of_thread ) {
     cpu_of_thread->dispatch_necessary = true;
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index bdb4370..335448d 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -243,10 +243,7 @@ bool _Thread_Initialize(
 
   _Thread_Action_control_initialize( &the_thread->Post_switch_actions );
 
-  _Thread_Action_initialize(
-    &the_thread->Life.Action,
-    _Thread_Life_action_handler
-  );
+  _Thread_Action_initialize( &the_thread->Life.Action );
   the_thread->Life.state = THREAD_LIFE_NORMAL;
   the_thread->Life.terminator = NULL;
 
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 6d90587..2b1fef9 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -176,6 +176,17 @@ void _Thread_Kill_zombies( void )
   _ISR_lock_Release_and_ISR_enable( &zombies->Lock, &lock_context );
 }
 
+static void _Thread_Add_life_change_action(
+  Thread_Control *the_thread
+)
+{
+  _Thread_Add_post_switch_action(
+    the_thread,
+    &the_thread->Life.Action,
+    _Thread_Life_action_handler
+  );
+}
+
 static void _Thread_Start_life_change_for_executing(
   Thread_Control *executing
 )
@@ -186,7 +197,7 @@ static void _Thread_Start_life_change_for_executing(
       || executing->current_state == STATES_SUSPENDED
   );
 
-  _Thread_Add_post_switch_action( executing, &executing->Life.Action );
+  _Thread_Add_life_change_action( executing );
 }
 
 void _Thread_Life_action_handler(
@@ -271,7 +282,7 @@ static void _Thread_Start_life_change(
     _Thread_Raise_real_priority_filter,
     false
   );
-  _Thread_Add_post_switch_action( the_thread, &the_thread->Life.Action );
+  _Thread_Add_life_change_action( the_thread );
   _Thread_Ready( the_thread );
 }
 




More information about the vc mailing list