[rtems commit] rtems: Use thread action for signals

Sebastian Huber sebh at rtems.org
Mon Mar 31 08:09:15 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Mar 14 11:53:43 2014 +0100

rtems: Use thread action for signals

---

 cpukit/rtems/include/rtems/rtems/signalimpl.h |    8 ++++++++
 cpukit/rtems/include/rtems/rtems/tasks.h      |    6 ++++++
 cpukit/rtems/src/signalcatch.c                |   20 +++++++++++---------
 cpukit/rtems/src/signalsend.c                 |    4 ++++
 cpukit/rtems/src/taskmode.c                   |    4 ++++
 cpukit/rtems/src/tasks.c                      |    4 +++-
 6 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/cpukit/rtems/include/rtems/rtems/signalimpl.h b/cpukit/rtems/include/rtems/rtems/signalimpl.h
index 700d1b7..ddbe00b 100644
--- a/cpukit/rtems/include/rtems/rtems/signalimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/signalimpl.h
@@ -18,6 +18,7 @@
 #define _RTEMS_RTEMS_SIGNALIMPL_H
 
 #include <rtems/rtems/signal.h>
+#include <rtems/score/thread.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -39,6 +40,13 @@ extern "C" {
  */
 void _Signal_Manager_initialization( void );
 
+void _Signal_Action_handler(
+  Thread_Control *thread,
+  Thread_Action *action,
+  Per_CPU_Control *cpu,
+  ISR_Level level
+);
+
 /**@}*/
 
 #ifdef __cplusplus
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index ead71b9..325723f 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -559,6 +559,12 @@ typedef struct {
   Event_Control            System_event;
   /** This field contains the Classic API Signal information for this task. */
   ASR_Information          Signal;
+
+  /**
+   * @brief Signal post-switch action in case signals are pending.
+   */
+  Thread_Action            Signal_action;
+
   /**
    *  This field contains the notepads for this task.
    *
diff --git a/cpukit/rtems/src/signalcatch.c b/cpukit/rtems/src/signalcatch.c
index 67c78b5..1bbeea7 100644
--- a/cpukit/rtems/src/signalcatch.c
+++ b/cpukit/rtems/src/signalcatch.c
@@ -18,20 +18,29 @@
 #include "config.h"
 #endif
 
-#include <rtems/rtems/signal.h>
+#include <rtems/rtems/signalimpl.h>
 #include <rtems/rtems/asrimpl.h>
 #include <rtems/rtems/tasks.h>
 #include <rtems/score/apiext.h>
 #include <rtems/score/isrlevel.h>
 #include <rtems/score/threaddispatch.h>
+#include <rtems/score/threadimpl.h>
 
-static void _RTEMS_signal_Post_switch_hook( Thread_Control *executing )
+void _Signal_Action_handler(
+  Thread_Control  *executing,
+  Thread_Action   *action,
+  Per_CPU_Control *cpu,
+  ISR_Level        level
+)
 {
   RTEMS_API_Control *api;
   ASR_Information   *asr;
   rtems_signal_set   signal_set;
   Modes_Control      prev_mode;
 
+  (void) action;
+  _Thread_Action_release_and_ISR_enable( cpu, level );
+
   api = executing->API_Extensions[ THREAD_API_RTEMS ];
   if ( !api )
     return;
@@ -53,13 +62,8 @@ static void _RTEMS_signal_Post_switch_hook( Thread_Control *executing )
 
   asr->nest_level -= 1;
   rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode );
-
 }
 
-static API_extensions_Post_switch_control _RTEMS_signal_Post_switch = {
-  .hook = _RTEMS_signal_Post_switch_hook
-};
-
 rtems_status_code rtems_signal_catch(
   rtems_asr_entry   asr_handler,
   rtems_mode        mode_set
@@ -76,8 +80,6 @@ rtems_status_code rtems_signal_catch(
   _Thread_Disable_dispatch(); /* cannot reschedule while */
                               /*   the thread is inconsistent */
 
-  _API_extensions_Add_post_switch( &_RTEMS_signal_Post_switch );
-
   if ( !_ASR_Is_null_handler( asr_handler ) ) {
     asr->mode_set = mode_set;
     asr->handler = asr_handler;
diff --git a/cpukit/rtems/src/signalsend.c b/cpukit/rtems/src/signalsend.c
index 579cc58..cb989c4 100644
--- a/cpukit/rtems/src/signalsend.c
+++ b/cpukit/rtems/src/signalsend.c
@@ -47,6 +47,10 @@ rtems_status_code rtems_signal_send(
       if ( ! _ASR_Is_null_handler( asr->handler ) ) {
         if ( asr->is_enabled ) {
           _ASR_Post_signals( asr, signal_set, &asr->signals_posted );
+          _Thread_Add_post_switch_action(
+            the_thread,
+            &api->Signal_action
+          );
           _Thread_Signal_notification( the_thread );
         } 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 c08c290..2bcbd1d 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -128,6 +128,10 @@ rtems_status_code rtems_task_mode(
       _ASR_Swap_signals( asr );
       if ( _ASR_Are_signals_pending( asr ) ) {
         needs_asr_dispatching = true;
+        _Thread_Add_post_switch_action(
+          executing,
+          &api->Signal_action
+        );
       }
     }
   }
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index 7e61068..c859d24 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -22,13 +22,14 @@
 #include <rtems/config.h>
 #include <rtems/rtems/asrimpl.h>
 #include <rtems/rtems/eventimpl.h>
+#include <rtems/rtems/signalimpl.h>
 #include <rtems/rtems/status.h>
 #include <rtems/rtems/support.h>
 #include <rtems/rtems/modes.h>
 #include <rtems/rtems/tasksimpl.h>
 #include <rtems/posix/keyimpl.h>
 #include <rtems/score/stack.h>
-#include <rtems/score/thread.h>
+#include <rtems/score/threadimpl.h>
 #include <rtems/score/userextimpl.h>
 #include <rtems/score/wkspace.h>
 #include <rtems/score/apiext.h>
@@ -70,6 +71,7 @@ static bool _RTEMS_tasks_Create_extension(
   _Event_Initialize( &api->Event );
   _Event_Initialize( &api->System_event );
   _ASR_Initialize( &api->Signal );
+  _Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler );
   created->task_variables = NULL;
 
   if ( rtems_configuration_get_notepads_enabled() ) {




More information about the vc mailing list