1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:47:35 +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:
Andreas Kling 2019-12-30 19:23:13 +01:00
parent 50677bf806
commit 610f3ad12f
7 changed files with 46 additions and 2 deletions

View file

@ -49,6 +49,7 @@ public:
explicit Thread(Process&);
~Thread();
static Thread* from_tid(int);
static void initialize();
static void finalize_dying_threads();
@ -61,7 +62,10 @@ public:
void set_priority(u32 p) { m_priority = p; }
u32 priority() const { return m_priority; }
u32 effective_priority() const { return m_priority + m_extra_priority; }
void set_priority_boost(u32 boost) { m_priority_boost = boost; }
u32 priority_boost() const { return m_priority_boost; }
u32 effective_priority() const { return m_priority + m_priority_boost + m_extra_priority; }
void set_joinable(bool j) { m_is_joinable = j; }
bool is_joinable() const { return m_is_joinable; }
@ -452,6 +456,7 @@ private:
String m_name;
u32 m_priority { THREAD_PRIORITY_NORMAL };
u32 m_extra_priority { 0 };
u32 m_priority_boost { 0 };
bool m_has_used_fpu { false };
bool m_dump_backtrace_on_finalization { false };
bool m_should_die { false };