Kernel: Scheduler now uses the new LinkedList API for moving threads

Scheduler doesn't have to depend on the fact that allocations should
work when same amount of memory is just deallocated
This commit is contained in:
2024-02-01 14:22:08 +02:00
parent c4bf1641bd
commit c69efc040c
2 changed files with 52 additions and 60 deletions

View File

@@ -44,34 +44,26 @@ namespace Kernel
BAN::ErrorOr<void> add_thread(Thread*);
private:
struct ActiveThread
struct SchedulerThread
{
ActiveThread(Thread* thread) : thread(thread) {}
Thread* thread;
uint64_t padding;
};
SchedulerThread(Thread* thread)
: thread(thread)
{}
struct SleepingThread
{
SleepingThread(Thread* thread, uint64_t wake_time) : thread(thread), wake_time(wake_time) {}
Thread* thread;
uint64_t wake_time;
};
struct BlockingThread
{
BlockingThread(Thread* thread, Semaphore* semaphore) : thread(thread), semaphore(semaphore) {}
Thread* thread;
Semaphore* semaphore;
uint8_t padding[sizeof(uint64_t) - sizeof(Semaphore*)];
union
{
uint64_t wake_time;
Semaphore* semaphore;
};
};
Thread* m_idle_thread { nullptr };
BAN::LinkedList<ActiveThread> m_active_threads;
BAN::LinkedList<SleepingThread> m_sleeping_threads;
BAN::LinkedList<BlockingThread> m_blocking_threads;
BAN::LinkedList<SchedulerThread> m_active_threads;
BAN::LinkedList<SchedulerThread> m_sleeping_threads;
BAN::LinkedList<SchedulerThread> m_blocking_threads;
BAN::LinkedList<ActiveThread>::iterator m_current_thread;
BAN::LinkedList<SchedulerThread>::iterator m_current_thread;
friend class Process;
};