[rtems commit] posix: Use thread action for signals

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


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

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

posix: Use thread action for signals

---

 cpukit/posix/include/rtems/posix/psignalimpl.h |   12 ++++++------
 cpukit/posix/include/rtems/posix/threadsup.h   |    5 +++++
 cpukit/posix/src/killinfo.c                    |    2 --
 cpukit/posix/src/psignal.c                     |   23 ++++++++++-------------
 cpukit/posix/src/psignalunblockthread.c        |    2 ++
 cpukit/posix/src/pthread.c                     |    5 +++++
 cpukit/posix/src/pthreadkill.c                 |    2 --
 7 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h
index 17ce19f..81561e2 100644
--- a/cpukit/posix/include/rtems/posix/psignalimpl.h
+++ b/cpukit/posix/include/rtems/posix/psignalimpl.h
@@ -69,8 +69,6 @@ extern Chain_Control _POSIX_signals_Inactive_siginfo;
 
 extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
 
-extern API_extensions_Post_switch_control _POSIX_signals_Post_switch;
-
 /*
  *  Internal routines
  */
@@ -86,10 +84,12 @@ void _POSIX_signals_Manager_Initialization(void);
 #define _POSIX_signals_Release( lock_context ) \
   _ISR_lock_Release_and_ISR_enable( &_POSIX_signals_Lock, lock_context )
 
-static inline void _POSIX_signals_Add_post_switch_extension(void)
-{
-  _API_extensions_Add_post_switch( &_POSIX_signals_Post_switch );
-}
+void _POSIX_signals_Action_handler(
+  Thread_Control  *executing,
+  Thread_Action   *action,
+  Per_CPU_Control *cpu,
+  ISR_Level        level
+);
 
 /**
  * @brief Unlock POSIX signals thread.
diff --git a/cpukit/posix/include/rtems/posix/threadsup.h b/cpukit/posix/include/rtems/posix/threadsup.h
index e0b9ff5..46903fe 100644
--- a/cpukit/posix/include/rtems/posix/threadsup.h
+++ b/cpukit/posix/include/rtems/posix/threadsup.h
@@ -68,6 +68,11 @@ typedef struct {
   /** This is the set of signals which are currently pending. */
   sigset_t                signals_pending;
 
+  /**
+   * @brief Signal post-switch action in case signals are pending.
+   */
+  Thread_Action           Signal_action;
+
   /*******************************************************************/
   /*******************************************************************/
   /***************         POSIX Cancelability         ***************/
diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c
index fa4857d..5d3dded 100644
--- a/cpukit/posix/src/killinfo.c
+++ b/cpukit/posix/src/killinfo.c
@@ -121,8 +121,6 @@ int killinfo(
 
   _Thread_Disable_dispatch();
 
-  _POSIX_signals_Add_post_switch_extension();
-
   /*
    *  Is the currently executing thread interested?  If so then it will
    *  get it an execute it as soon as the dispatcher executes.
diff --git a/cpukit/posix/src/psignal.c b/cpukit/posix/src/psignal.c
index 731a230..0e2a018 100644
--- a/cpukit/posix/src/psignal.c
+++ b/cpukit/posix/src/psignal.c
@@ -25,6 +25,7 @@
 
 #include <rtems/score/isrlevel.h>
 #include <rtems/score/statesimpl.h>
+#include <rtems/score/threadimpl.h>
 #include <rtems/score/threadqimpl.h>
 #include <rtems/score/watchdogimpl.h>
 #include <rtems/score/wkspace.h>
@@ -108,22 +109,22 @@ Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
     (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \
       (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL))
 
-/*
- *  _POSIX_signals_Post_switch_extension
- */
-
-static void _POSIX_signals_Post_switch_hook(
-  Thread_Control  *the_thread
+void _POSIX_signals_Action_handler(
+  Thread_Control  *executing,
+  Thread_Action   *action,
+  Per_CPU_Control *cpu,
+  ISR_Level        level
 )
 {
   POSIX_API_Control  *api;
   int                 signo;
   ISR_lock_Context    lock_context;
   int                 hold_errno;
-  Thread_Control     *executing;
 
-  executing = _Thread_Get_executing();
-  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
+  (void) action;
+  _Thread_Action_release_and_ISR_enable( cpu, level );
+
+  api = executing->API_Extensions[ THREAD_API_POSIX ];
 
   /*
    *  We need to ensure that if the signal handler executes a call
@@ -169,10 +170,6 @@ static void _POSIX_signals_Post_switch_hook(
   executing->Wait.return_code = hold_errno;
 }
 
-API_extensions_Post_switch_control _POSIX_signals_Post_switch = {
-  .hook = _POSIX_signals_Post_switch_hook
-};
-
 void _POSIX_signals_Manager_Initialization(void)
 {
   uint32_t   signo;
diff --git a/cpukit/posix/src/psignalunblockthread.c b/cpukit/posix/src/psignalunblockthread.c
index 2d6063b..c93dcfc 100644
--- a/cpukit/posix/src/psignalunblockthread.c
+++ b/cpukit/posix/src/psignalunblockthread.c
@@ -47,6 +47,8 @@ bool _POSIX_signals_Unblock_thread(
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
+  _Thread_Add_post_switch_action( the_thread, &api->Signal_action );
+
   mask = signo_to_mask( signo );
 
   /*
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 7968f17..d2e6373 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -233,6 +233,11 @@ static bool _POSIX_Threads_Create_extension(
     api->signals_blocked = SIGNAL_ALL_MASK;
   }
 
+  _Thread_Action_initialize(
+    &api->Signal_action,
+    _POSIX_signals_Action_handler
+  );
+
   _Thread_queue_Initialize(
     &api->Join_List,
     THREAD_QUEUE_DISCIPLINE_FIFO,
diff --git a/cpukit/posix/src/pthreadkill.c b/cpukit/posix/src/pthreadkill.c
index dce646b..2e44dc6 100644
--- a/cpukit/posix/src/pthreadkill.c
+++ b/cpukit/posix/src/pthreadkill.c
@@ -53,8 +53,6 @@ int pthread_kill(
        *  If sig == 0 then just validate arguments
        */
 
-      _POSIX_signals_Add_post_switch_extension();
-
       api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
       if ( sig ) {




More information about the vc mailing list