diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-30 19:23:13 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-30 19:23:13 +0100 |
commit | 610f3ad12fc023dee0e71bead17cf6ebd4eba09a (patch) | |
tree | 96c343455878f120d481d9c557100585908e2eb5 /Kernel/Thread.cpp | |
parent | 50677bf806e73d6b2bf940e0192f170b7bbaf3e4 (diff) | |
download | serenity-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.cpp | 12 |
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; +} |