mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:45:10 +00:00
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:
parent
50677bf806
commit
610f3ad12f
7 changed files with 46 additions and 2 deletions
|
@ -3906,3 +3906,19 @@ int Process::sys$futex(const Syscall::SC_futex_params* params)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$set_thread_boost(int tid, int amount)
|
||||
{
|
||||
if (amount < 0 || amount > 20)
|
||||
return -EINVAL;
|
||||
InterruptDisabler disabler;
|
||||
auto* thread = Thread::from_tid(tid);
|
||||
if (!thread)
|
||||
return -ESRCH;
|
||||
if (thread->state() == Thread::State::Dead || thread->state() == Thread::State::Dying)
|
||||
return -ESRCH;
|
||||
if (!is_superuser() && thread->process().uid() != euid())
|
||||
return -EPERM;
|
||||
thread->set_priority_boost(amount);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue