From 0dd732ddac636e4b568172fa1b0a87e9191c8aba Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 14 Mar 2014 11:50:58 +0100 Subject: score: Add thread actions Thread actions are the building block for efficient implementation of - Classic signals delivery, - POSIX signals delivery, - thread restart notification, - thread delete notification, - forced thread migration on SMP configurations, and - the Multiprocessor Resource Sharing Protocol (MrsP). --- cpukit/score/src/threaddispatch.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'cpukit/score/src/threaddispatch.c') diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c index 22a4f8881d..ae30c0c7d3 100644 --- a/cpukit/score/src/threaddispatch.c +++ b/cpukit/score/src/threaddispatch.c @@ -9,6 +9,8 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2014 embedded brains GmbH. + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -27,6 +29,36 @@ #include #include +static Thread_Action *_Thread_Get_post_switch_action( + Thread_Control *executing +) +{ + Chain_Control *chain = &executing->Post_switch_actions.Chain; + + return (Thread_Action *) _Chain_Get_unprotected( chain ); +} + +static void _Thread_Run_post_switch_actions( Thread_Control *executing ) +{ + ISR_Level level; + Per_CPU_Control *cpu; + Thread_Action *action; + + cpu = _Thread_Action_ISR_disable_and_acquire( executing, &level ); + action = _Thread_Get_post_switch_action( executing ); + + while ( action != NULL ) { + _Chain_Set_off_chain( &action->Node ); + + ( *action->handler )( executing, action, cpu, level ); + + cpu = _Thread_Action_ISR_disable_and_acquire( executing, &level ); + action = _Thread_Get_post_switch_action( executing ); + } + + _Thread_Action_release_and_ISR_enable( cpu, level ); +} + void _Thread_Dispatch( void ) { Per_CPU_Control *per_cpu; @@ -176,4 +208,5 @@ post_switch: _Per_CPU_Release_and_ISR_enable( per_cpu, level ); _API_extensions_Run_post_switch( executing ); + _Thread_Run_post_switch_actions( executing ); } -- cgit v1.2.3