Browse Source

Kernel: Add Processor::time_spent_idle()

Idan Horowitz 3 years ago
parent
commit
900fac27c6
2 changed files with 7 additions and 0 deletions
  1. 2 0
      Kernel/Arch/x86/Processor.h
  2. 5 0
      Kernel/Arch/x86/common/Processor.cpp

+ 2 - 0
Kernel/Arch/x86/Processor.h

@@ -258,6 +258,8 @@ public:
 
 
     ALWAYS_INLINE ProcessorInfo& info() { return *m_info; }
     ALWAYS_INLINE ProcessorInfo& info() { return *m_info; }
 
 
+    u64 time_spent_idle() const;
+
     static bool is_smp_enabled();
     static bool is_smp_enabled();
 
 
     ALWAYS_INLINE static Processor& current()
     ALWAYS_INLINE static Processor& current()

+ 5 - 0
Kernel/Arch/x86/common/Processor.cpp

@@ -1323,4 +1323,9 @@ void Processor::assume_context(Thread& thread, FlatPtr flags)
     VERIFY_NOT_REACHED();
     VERIFY_NOT_REACHED();
 }
 }
 
 
+u64 Processor::time_spent_idle() const
+{
+    return m_idle_thread->time_in_user() + m_idle_thread->time_in_kernel();
+}
+
 }
 }