1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

Kernel: Implement thread priority queues

Rather than walking all Thread instances and putting them into
a vector to be sorted by priority, queue them into priority sorted
linked lists as soon as they become ready to be executed.
This commit is contained in:
Tom 2021-01-22 16:56:08 -07:00 committed by Andreas Kling
parent c531084873
commit 03a9ee79fa
5 changed files with 124 additions and 58 deletions

View file

@ -83,6 +83,7 @@ class Thread
friend class Process;
friend class Scheduler;
friend class ThreadReadyQueue;
public:
inline static Thread* current()
@ -102,7 +103,7 @@ public:
void set_priority(u32 p) { m_priority = p; }
u32 priority() const { return m_priority; }
u32 effective_priority() const;
u32 effective_priority() const { return m_priority; }
void detach()
{
@ -1170,6 +1171,7 @@ public:
private:
IntrusiveListNode m_runnable_list_node;
int m_runnable_priority { -1 };
private:
friend struct SchedulerData;
@ -1243,6 +1245,7 @@ private:
TSS32 m_tss;
TrapFrame* m_current_trap { nullptr };
u32 m_saved_critical { 1 };
IntrusiveListNode m_ready_queue_node;
Atomic<u32> m_cpu { 0 };
u32 m_cpu_affinity { THREAD_AFFINITY_DEFAULT };
u32 m_ticks_left { 0 };
@ -1294,7 +1297,6 @@ private:
State m_state { Invalid };
String m_name;
u32 m_priority { THREAD_PRIORITY_NORMAL };
u32 m_extra_priority { 0 };
State m_stop_state { Invalid };