diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-07-17 11:03:02 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-07-17 13:09:49 +0200 |
commit | f74d9496ee4d0a8af72adbbda2e59d9b1d005423 (patch) | |
tree | 2a00efc7ebbf3f43d41d3439a410ef271417cc8b | |
parent | libcsupport: Use _reclaim_reent() (diff) | |
download | rtems-f74d9496ee4d0a8af72adbbda2e59d9b1d005423.tar.bz2 |
score: Add _Thread_Get_executing()
-rw-r--r-- | cpukit/score/include/rtems/score/thread.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index 13b7e7516d..5e8bc950a7 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -66,6 +66,7 @@ extern "C" { #include <rtems/score/percpu.h> #include <rtems/score/context.h> #include <rtems/score/cpu.h> +#include <rtems/score/isr.h> #if defined(RTEMS_MULTIPROCESSING) #include <rtems/score/mppkt.h> #endif @@ -882,6 +883,34 @@ void _Thread_blocking_operation_Cancel( ISR_Level level ); +/** + * @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 Thread_Control *_Thread_Get_executing( void ) +{ + Thread_Control *executing; + + #if defined( RTEMS_SMP ) + ISR_Level level; + + _ISR_Disable( level ); + #endif + + executing = _Thread_Executing; + + #if defined( RTEMS_SMP ) + _ISR_Enable( level ); + #endif + + return executing; +} + #ifndef __RTEMS_APPLICATION__ #include <rtems/score/thread.inl> #endif |