Add thread preemption when a thread wakes up from a timeout

This commit is contained in:
wheremyfoodat 2025-02-03 00:16:24 +02:00
parent 86d1bde845
commit 54cdcacd5a
6 changed files with 54 additions and 3 deletions

View file

@ -58,6 +58,7 @@ class Kernel {
// Top 8 bits are the major version, bottom 8 are the minor version
u16 kernelVersion = 0;
u64 nextScheduledWakeupTick = std::numeric_limits<u64>::max();
// Shows whether a reschedule will be need
bool needReschedule = false;
@ -214,6 +215,8 @@ public:
}
}
void addWakeupEvent(u64 tick);
Handle makeObject(KernelObjectType type) {
if (handleCounter > KernelHandles::Max) [[unlikely]] {
Helpers::panic("Hlep we somehow created enough kernel objects to overflow this thing");
@ -253,5 +256,7 @@ public:
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }
void clearInstructionCache();
void clearInstructionCacheRange(u32 start, u32 size);
void pollThreadWakeups();
u32 getSharedFontVaddr();
};

View file

@ -11,7 +11,8 @@ struct Scheduler {
VBlank = 0, // End of frame event
UpdateTimers = 1, // Update kernel timer objects
RunDSP = 2, // Make the emulated DSP run for one audio frame
SignalY2R = 3, // Signal that a Y2R conversion has finished
ThreadWakeup = 3, // A thread is going to wake up and we need to reschedule threads
SignalY2R = 4, // Signal that a Y2R conversion has finished
Panic = 4, // Dummy event that is always pending and should never be triggered (Timestamp = UINT64_MAX)
TotalNumberOfEvents // How many event types do we have in total?
};