فهرست منبع

Kernel: Add a Thread::all_threads() helper.

Andreas Kling 6 سال پیش
والد
کامیت
fa7f532c35
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 9 0
      Kernel/Thread.cpp
  2. 2 0
      Kernel/Thread.h

+ 9 - 0
Kernel/Thread.cpp

@@ -522,3 +522,12 @@ void Thread::initialize()
     g_threads = new InlineLinkedList<Thread>;
     Scheduler::initialize();
 }
+
+Vector<Thread*> Thread::all_threads()
+{
+    Vector<Thread*> threads;
+    InterruptDisabler disabler;
+    for (auto* thread = g_threads->head(); thread; thread = thread->next())
+        threads.append(thread);
+    return threads;
+}

+ 2 - 0
Kernel/Thread.h

@@ -32,6 +32,8 @@ public:
     static void initialize();
     static void finalize_dying_threads();
 
+    static Vector<Thread*> all_threads();
+
     int tid() const { return m_tid; }
     int pid() const;