diff --git a/miosix/kernel/cpu_time_counter.cpp b/miosix/kernel/cpu_time_counter.cpp
index ea57ed481d9560c614445c2e9a3a6e9e018d09c5..854a350769bc172aab5b32f9b963be799c56e69e 100644
--- a/miosix/kernel/cpu_time_counter.cpp
+++ b/miosix/kernel/cpu_time_counter.cpp
@@ -26,6 +26,7 @@
  ***************************************************************************/
 
 #include "cpu_time_counter.h"
+#include "cpu_time_counter_private.h"
 #include "kernel/kernel.h"
 
 #ifdef WITH_CPU_TIME_COUNTER
@@ -36,6 +37,18 @@ Thread *CPUTimeCounter::head = nullptr;
 Thread *CPUTimeCounter::tail = nullptr;
 volatile unsigned int CPUTimeCounter::nThreads = 0;
 
+long long CPUTimeCounter::getActiveThreadTime()
+{
+    long long curTime, usedTime, lastAct;
+    {
+        PauseKernelLock pk;
+        curTime = IRQgetTime();
+        usedTime = runningThread->timeCounterData.usedCpuTime;
+        lastAct = runningThread->timeCounterData.lastActivation;
+    }
+    return usedTime + (curTime - lastAct);
+}
+
 void CPUTimeCounter::PKremoveDeadThreads()
 {
     Thread *prev = nullptr;
diff --git a/miosix/kernel/cpu_time_counter.h b/miosix/kernel/cpu_time_counter.h
index d9e0f998ca55b53b3e83f7db675d9935014c5fce..6e05ea083b752f2626e302792d8724c1e5f350b1 100644
--- a/miosix/kernel/cpu_time_counter.h
+++ b/miosix/kernel/cpu_time_counter.h
@@ -148,6 +148,12 @@ public:
         return iterator(nullptr);
     }
 
+    /**
+     * \returns the amount of CPU run-time consumed up to now by the currently
+     * active thread.
+     */
+    static long long getActiveThreadTime();
+
 private:
     // The following methods are called from basic_scheduler to notify
     // CPUTimeCounter of various events.