From f74d9496ee4d0a8af72adbbda2e59d9b1d005423 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 17 Jul 2013 11:03:02 +0200 Subject: score: Add _Thread_Get_executing() --- cpukit/score/include/rtems/score/thread.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cpukit/score') 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 #include #include +#include #if defined(RTEMS_MULTIPROCESSING) #include #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 #endif -- cgit v1.2.3