summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-14 11:53:43 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-31 08:29:42 +0200
commit6fd1bdb7af578933f1aa8fb981a29c61df5dcde4 (patch)
treea89b37b37c4cbcb4d8c7a6478a4aa5b6ab279dde
parentscore: Add thread actions (diff)
downloadrtems-6fd1bdb7af578933f1aa8fb981a29c61df5dcde4.tar.bz2
rtems: Use thread action for signals
-rw-r--r--cpukit/rtems/include/rtems/rtems/signalimpl.h8
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h6
-rw-r--r--cpukit/rtems/src/signalcatch.c20
-rw-r--r--cpukit/rtems/src/signalsend.c4
-rw-r--r--cpukit/rtems/src/taskmode.c4
-rw-r--r--cpukit/rtems/src/tasks.c4
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 700d1b76c3..ddbe00ba5e 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 ead71b9f4a..325723ff85 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 67c78b55c7..1bbeea727f 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 579cc58b1c..cb989c4cbf 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 c08c29009c..2bcbd1de33 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 7e61068796..c859d248b5 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() ) {