summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/include/rtems/score/thread.h')
-rw-r--r--cpukit/score/include/rtems/score/thread.h29
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