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. :^)
This commit is contained in:
Andreas Kling 2019-12-30 19:23:13 +01:00
commit 610f3ad12f
Notes: sideshowbarker 2024-07-19 10:31:52 +09:00
7 changed files with 46 additions and 2 deletions

View file

@ -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;
}