summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/waitid.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-09-27 08:53:35 -0600
committerAndreas Kling <kling@serenityos.org>2020-09-27 19:46:04 +0200
commit838d9fa251ed34289cb9c77eb46f889dc9e79416 (patch)
tree0efecf56806d2fff7ebfbe5b28288a8ac01c5600 /Kernel/Syscalls/waitid.cpp
parent079486ed7eba3d15567bb5ee9677c81dd190cffa (diff)
downloadserenity-838d9fa251ed34289cb9c77eb46f889dc9e79416.zip
Kernel: Make Thread refcounted
Similar to Process, we need to make Thread refcounted. This will solve problems that will appear once we schedule threads on more than one processor. This allows us to hold onto threads without necessarily holding the scheduler lock for the entire duration.
Diffstat (limited to 'Kernel/Syscalls/waitid.cpp')
-rw-r--r--Kernel/Syscalls/waitid.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/Syscalls/waitid.cpp b/Kernel/Syscalls/waitid.cpp
index f4d6f9c7ad..9e75ba376e 100644
--- a/Kernel/Syscalls/waitid.cpp
+++ b/Kernel/Syscalls/waitid.cpp
@@ -68,7 +68,9 @@ KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
return reap(*waitee_process);
} else {
// FIXME: PID/TID BUG
- auto* waitee_thread = Thread::from_tid(waitee_pid.value());
+ // Make sure to hold the scheduler lock so that we operate on a consistent state
+ ScopedSpinLock scheduler_lock(g_scheduler_lock);
+ auto waitee_thread = Thread::from_tid(waitee_pid.value());
if (!waitee_thread)
return KResult(-ECHILD);
ASSERT((options & WNOHANG) || waitee_thread->state() == Thread::State::Stopped);