diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-14 11:50:58 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-31 08:29:42 +0200 |
commit | 0dd732ddac636e4b568172fa1b0a87e9191c8aba (patch) | |
tree | 0dcda146d77e892286358052071d4320420a8809 /cpukit/score/src/threaddispatch.c | |
parent | score: Add and use thread get/set CPU functions (diff) | |
download | rtems-0dd732ddac636e4b568172fa1b0a87e9191c8aba.tar.bz2 |
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).
Diffstat (limited to 'cpukit/score/src/threaddispatch.c')
-rw-r--r-- | cpukit/score/src/threaddispatch.c | 33 |
1 files changed, 33 insertions, 0 deletions
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 <rtems/score/userextimpl.h> #include <rtems/score/wkspace.h> +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 ); } |