diff options
Diffstat (limited to '')
-rw-r--r-- | cpukit/posix/src/pthread.c | 11 | ||||
-rw-r--r-- | cpukit/rtems/src/tasks.c | 11 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/apiext.h | 59 | ||||
-rw-r--r-- | cpukit/score/src/apiext.c | 11 | ||||
-rw-r--r-- | cpukit/score/src/threaddispatch.c | 4 |
5 files changed, 71 insertions, 25 deletions
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index cd2cffec9e..e6f928941d 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -305,12 +305,14 @@ static void _POSIX_Threads_Initialize_user_threads( void ) * API Extension control structures */ API_extensions_Control _POSIX_Threads_API_extensions = { - { NULL, NULL }, #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) - NULL, /* predriver */ + .predriver_hook = NULL, #endif - _POSIX_Threads_Initialize_user_threads, /* postdriver */ - _POSIX_signals_Post_switch_extension, /* post switch */ + .postdriver_hook = _POSIX_Threads_Initialize_user_threads +}; + +API_extensions_Post_switch_control _POSIX_Threads_API_extensions_post_switch = { + .hook = _POSIX_signals_Post_switch_extension }; User_extensions_Control _POSIX_Threads_User_extensions = { @@ -357,6 +359,7 @@ void _POSIX_Threads_Manager_initialization(void) _User_extensions_Add_API_set( &_POSIX_Threads_User_extensions ); _API_extensions_Add( &_POSIX_Threads_API_extensions ); + _API_extensions_Add_post_switch( &_POSIX_Threads_API_extensions_post_switch ); /* * If we supported MP, then here we would ... diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c index 2385cb2d22..2d7784f777 100644 --- a/cpukit/rtems/src/tasks.c +++ b/cpukit/rtems/src/tasks.c @@ -213,12 +213,14 @@ static void _RTEMS_tasks_Post_switch_extension( } API_extensions_Control _RTEMS_tasks_API_extensions = { - { NULL, NULL }, #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) - NULL, /* predriver */ + .predriver_hook = NULL, #endif - _RTEMS_tasks_Initialize_user_tasks, /* postdriver */ - _RTEMS_tasks_Post_switch_extension /* post switch */ + .postdriver_hook = _RTEMS_tasks_Initialize_user_tasks +}; + +API_extensions_Post_switch_control _RTEMS_tasks_API_extensions_post_switch = { + .hook = _RTEMS_tasks_Post_switch_extension }; User_extensions_Control _RTEMS_tasks_User_extensions = { @@ -260,6 +262,7 @@ void _RTEMS_tasks_Manager_initialization(void) _User_extensions_Add_API_set( &_RTEMS_tasks_User_extensions ); _API_extensions_Add( &_RTEMS_tasks_API_extensions ); + _API_extensions_Add_post_switch( &_RTEMS_tasks_API_extensions_post_switch ); /* * Register the MP Process Packet routine. diff --git a/cpukit/score/include/rtems/score/apiext.h b/cpukit/score/include/rtems/score/apiext.h index 82910bfc0d..db77a8b9c8 100644 --- a/cpukit/score/include/rtems/score/apiext.h +++ b/cpukit/score/include/rtems/score/apiext.h @@ -46,9 +46,9 @@ typedef void (*API_extensions_Postdriver_hook)(void); /** - * This type defines the prototype of the Postswitch Hook. + * This type defines the prototype of the Post Switch Hook. */ -typedef void (*API_extensions_Postswitch_hook)( +typedef void (*API_extensions_Post_switch_hook)( Thread_Control * ); @@ -77,20 +77,34 @@ typedef struct { * @note If this field is NULL, no extension is invoked. */ API_extensions_Postdriver_hook postdriver_hook; +} API_extensions_Control; + +/** + * @brief Control structure for post switch hooks. + */ +typedef struct { + Chain_Node Node; + /** - * This field is the callout invoked during each context switch - * in the context of the heir thread. + * @brief The hook invoked during each context switch in the context of the + * heir thread. * - * @note If this field is NULL, no extension is invoked. + * This hook must not be NULL. */ - API_extensions_Postswitch_hook postswitch_hook; -} API_extensions_Control; + API_extensions_Post_switch_hook hook; +} API_extensions_Post_switch_control; /** * This is the list of API extensions to the system initialization. */ SCORE_EXTERN Chain_Control _API_extensions_List; + +/** + * @brief The API extensions post switch list. + */ +SCORE_EXTERN Chain_Control _API_extensions_Post_switch_list; + /** * @brief Initialize the API Extensions Handler * @@ -109,6 +123,23 @@ void _API_extensions_Add( API_extensions_Control *the_extension ); +/** + * @brief Adds the API extension post switch control to the post switch list. + * + * The post switch control is only added to the list if it is in the off chain + * state. Thus this function can be called multiple times with the same + * post switch control and only the first invocation will actually add it to the + * list. + * + * There is no protection against concurrent access. This function must be + * called within a _Thread_Disable_dispatch() critical section. + * + * @param [in, out] post_switch The post switch control. + */ +void _API_extensions_Add_post_switch( + API_extensions_Post_switch_control *post_switch +); + #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) /** * @brief Execute all Pre-Driver Extensions @@ -126,21 +157,19 @@ void _API_extensions_Add( void _API_extensions_Run_postdriver( void ); /** - * @brief Execute all Post Context Switch Extensions - * - * This routine executes all of the post context switch callouts. + * @brief Runs all API extension post switch hooks. */ -static inline void _API_extensions_Run_postswitch( Thread_Control *executing ) +static inline void _API_extensions_Run_post_switch( Thread_Control *executing ) { - const Chain_Control *chain = &_API_extensions_List; + const Chain_Control *chain = &_API_extensions_Post_switch_list; const Chain_Node *tail = _Chain_Immutable_tail( chain ); const Chain_Node *node = _Chain_Immutable_first( chain ); while ( node != tail ) { - const API_extensions_Control *extension = - (const API_extensions_Control *) node; + const API_extensions_Post_switch_control *post_switch = + (const API_extensions_Post_switch_control *) node; - (*extension->postswitch_hook)( executing ); + (*post_switch->hook)( executing ); node = _Chain_Immutable_next( node ); } diff --git a/cpukit/score/src/apiext.c b/cpukit/score/src/apiext.c index 73dffee856..fbca353131 100644 --- a/cpukit/score/src/apiext.c +++ b/cpukit/score/src/apiext.c @@ -25,6 +25,7 @@ void _API_extensions_Initialization( void ) { _Chain_Initialize_empty( &_API_extensions_List ); + _Chain_Initialize_empty( &_API_extensions_Post_switch_list ); } void _API_extensions_Add( @@ -34,6 +35,16 @@ void _API_extensions_Add( _Chain_Append( &_API_extensions_List, &the_extension->Node ); } +void _API_extensions_Add_post_switch( + API_extensions_Post_switch_control *post_switch +) +{ + _Chain_Append_if_is_off_chain_unprotected( + &_API_extensions_Post_switch_list, + &post_switch->Node + ); +} + #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) void _API_extensions_Run_predriver( void ) diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c index 283d27880d..66c7bdcd43 100644 --- a/cpukit/score/src/threaddispatch.c +++ b/cpukit/score/src/threaddispatch.c @@ -69,7 +69,7 @@ void _Thread_Dispatch( void ) * * _Thread_Unnest_dispatch(); * - * _API_extensions_Run_postswitch(); + * _API_extensions_Run_post_switch(); * } * * The interrupt event makes task H ready. The interrupt code will see @@ -202,5 +202,5 @@ post_switch: _Thread_Unnest_dispatch(); #endif - _API_extensions_Run_postswitch( executing ); + _API_extensions_Run_post_switch( executing ); } |