diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-06-25 13:48:00 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-06-25 13:55:34 +0200 |
commit | bd67d7d2f8c9925517416b58196ca4c8fe389fef (patch) | |
tree | a339e9dcaeb25acfc7493919f16e8eb890fd8891 /cpukit/score/include/rtems/score/percpu.h | |
parent | score: Move default _ISR_Is_in_progress() (diff) | |
download | rtems-bd67d7d2f8c9925517416b58196ca4c8fe389fef.tar.bz2 |
score: Simplify <rtems/score/thread.h>
Avoid Thread_Control typedef in <rtems/score/percpu.h>. This helps to
get rid of the <rtems/score/percpu.h> include in <rtems/score/thread.h>
which exposes a lot of implementation details.
Diffstat (limited to 'cpukit/score/include/rtems/score/percpu.h')
-rw-r--r-- | cpukit/score/include/rtems/score/percpu.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h index 600f46e377..a6f7a25cc6 100644 --- a/cpukit/score/include/rtems/score/percpu.h +++ b/cpukit/score/include/rtems/score/percpu.h @@ -51,10 +51,7 @@ extern "C" { #if !defined( ASM ) -#ifndef __THREAD_CONTROL_DEFINED__ -#define __THREAD_CONTROL_DEFINED__ -typedef struct Thread_Control_struct Thread_Control; -#endif +struct Thread_Control; struct Scheduler_Context; @@ -276,7 +273,7 @@ typedef struct Per_CPU_Control { * configurations use _Thread_Is_executing_on_a_processor() to figure out if * a thread context is executing on a processor. */ - Thread_Control *executing; + struct Thread_Control *executing; /** * @brief This is the heir thread for this processor. @@ -290,7 +287,7 @@ typedef struct Per_CPU_Control { * * @see _Thread_Get_heir_and_make_it_executing(). */ - Thread_Control *heir; + struct Thread_Control *heir; /** * @brief This is set to true when this processor needs to run the @@ -595,6 +592,34 @@ bool _Per_CPU_State_wait_for_non_initial_state( #define _Thread_Time_of_last_context_switch \ _Per_CPU_Get()->time_of_last_context_switch +/** + * @brief Returns the thread control block of the executing thread. + * + * This function can be called in any context. On SMP configurations + * interrupts are disabled to ensure that the processor index is used + * consistently. + * + * @return The thread control block of the executing thread. + */ +RTEMS_INLINE_ROUTINE struct Thread_Control *_Thread_Get_executing( void ) +{ + struct Thread_Control *executing; + + #if defined( RTEMS_SMP ) + ISR_Level level; + + _ISR_Disable_without_giant( level ); + #endif + + executing = _Thread_Executing; + + #if defined( RTEMS_SMP ) + _ISR_Enable_without_giant( level ); + #endif + + return executing; +} + /**@}*/ #endif /* !defined( ASM ) */ |