summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-17 11:03:02 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-17 13:09:49 +0200
commitf74d9496ee4d0a8af72adbbda2e59d9b1d005423 (patch)
tree2a00efc7ebbf3f43d41d3439a410ef271417cc8b /cpukit/score/include
parentlibcsupport: Use _reclaim_reent() (diff)
downloadrtems-f74d9496ee4d0a8af72adbbda2e59d9b1d005423.tar.bz2
score: Add _Thread_Get_executing()
Diffstat (limited to 'cpukit/score/include')
-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