35 lines
1.4 KiB
C
35 lines
1.4 KiB
C
#pragma once
|
|
// ke_sched.h - Multi-Level Feedback Queue scheduler
|
|
// Three run queues (Low / Normal / High). IRQ 0 drives KeSchedulerTick.
|
|
#include <ke_thread.h>
|
|
|
|
#define QUANTUM_MS 10 // base time slice in milliseconds
|
|
|
|
// Called once by KernelMain before any threads are created.
|
|
void KeInitializeScheduler(void);
|
|
|
|
// Add / remove a thread from the run queues.
|
|
void KeReadyThread(THREAD* thread);
|
|
void KeUnreadyThread(THREAD* thread);
|
|
|
|
// Called from the timer ISR every QUANTUM_MS. This only performs timer
|
|
// accounting and requests a reschedule; the actual context switch happens from
|
|
// KiExitInterrupt after the IRQ handler has returned and EOI has been sent.
|
|
void KeSchedulerTick(void);
|
|
|
|
// Internal scheduler hooks used by the interrupt-exit path. KiRequestReschedule
|
|
// is cheap and can be called from interrupt context. KiScheduleFromInterrupt
|
|
// consumes the pending request and performs the context switch, if needed.
|
|
void KiRequestReschedule(void);
|
|
int KiIsReschedulePending(void);
|
|
void KiScheduleFromInterrupt(void);
|
|
|
|
// Voluntarily yield the CPU. Picks the next runnable thread immediately.
|
|
__declspec(dllexport) void KeYield(void);
|
|
|
|
// Returns the thread currently running on this CPU (reads GS:[0]).
|
|
THREAD* KeGetCurrentThread(void);
|
|
|
|
// Set the current-thread GS slot. Called once per CPU at boot.
|
|
void KeSetCurrentThread(THREAD* thread);
|