From 6fd1bdb7af578933f1aa8fb981a29c61df5dcde4 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 14 Mar 2014 11:53:43 +0100 Subject: 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 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 +#include #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 +#include #include #include #include #include #include +#include -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 #include #include +#include #include #include #include #include #include #include -#include +#include #include #include #include @@ -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() ) { -- cgit v1.2.3