summaryrefslogtreecommitdiff
path: root/Kernel/Thread.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-30 19:23:13 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-30 19:23:13 +0100
commit610f3ad12fc023dee0e71bead17cf6ebd4eba09a (patch)
tree96c343455878f120d481d9c557100585908e2eb5 /Kernel/Thread.cpp
parent50677bf806e73d6b2bf940e0192f170b7bbaf3e4 (diff)
downloadserenity-610f3ad12fc023dee0e71bead17cf6ebd4eba09a.zip
Kernel: Add a basic thread boosting mechanism
This patch introduces a syscall: int set_thread_boost(int tid, int amount) You can use this to add a permanent boost value to the effective thread priority of any thread with your UID (or any thread in the system if you are the superuser.) This is quite crude, but opens up some interesting opportunities. :^)
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r--Kernel/Thread.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 92078cae45..c5a9f638d0 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -786,3 +786,15 @@ void Thread::wake_from_queue()
ASSERT(state() == State::Queued);
set_state(State::Runnable);
}
+
+Thread* Thread::from_tid(int tid)
+{
+ ASSERT_INTERRUPTS_DISABLED();
+ Thread* found_thread = nullptr;
+ Thread::for_each([&](auto& thread) {
+ if (thread.tid() == tid)
+ found_thread = &thread;
+ return IterationDecision::Continue;
+ });
+ return found_thread;
+}