summaryrefslogtreecommitdiff
path: root/Kernel/Thread.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-01-26 14:16:07 -0700
committerAndreas Kling <kling@serenityos.org>2021-01-27 21:12:24 +0100
commit21d288a10e5a1a44e8852b70dd3bdfb619483180 (patch)
tree4f9329b50ba4cd625305296c5686bc9d0c787d74 /Kernel/Thread.h
parentf88a8b16d7391ccdb828f659e40b892fe8fdbc83 (diff)
downloadserenity-21d288a10e5a1a44e8852b70dd3bdfb619483180.zip
Kernel: Make Thread::current smp-safe
Change Thread::current to be a static function and read using the fs register, which eliminates a window between Processor::current() returning and calling a function on it, which can trigger preemption and a move to a different processor, which then causes operating on the wrong object.
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r--Kernel/Thread.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 4208f245fd..31d6a39f5f 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -87,7 +87,7 @@ class Thread
public:
inline static Thread* current()
{
- return Processor::current().current_thread();
+ return Processor::current_thread();
}
explicit Thread(NonnullRefPtr<Process>);