Browse Source

fix(syscall_exit): remove all thds from ready list

greatbridf 2 years ago
parent
commit
edb5ac858c
2 changed files with 14 additions and 4 deletions
  1. 9 1
      include/kernel/process.hpp
  2. 5 3
      src/kernel/syscall.cpp

+ 9 - 1
include/kernel/process.hpp

@@ -96,8 +96,11 @@ public:
 };
 
 class thdlist {
+public:
+    using list_type = types::list<thread>;
+
 private:
-    types::list<thread> thds;
+    list_type thds;
 
 public:
     constexpr thdlist(const thdlist& obj) = delete;
@@ -130,6 +133,11 @@ public:
     {
         return thds.size();
     }
+
+    constexpr list_type& underlying_list(void)
+    {
+        return thds;
+    }
 };
 
 class process {

+ 5 - 3
src/kernel/syscall.cpp

@@ -132,9 +132,11 @@ void _syscall_exit(interrupt_stack* data)
 
     // terminating a whole process:
 
-    // remove this thread from ready list
-    current_thread->attr.ready = 0;
-    readythds->remove_all(current_thread);
+    // remove threads from ready list
+    for (auto& thd : current_process->thds.underlying_list()) {
+        thd.attr.ready = 0;
+        readythds->remove_all(&thd);
+    }
 
     // TODO: write back mmap'ped files and close them