This commit is contained in:
wheremyfoodat 2025-03-17 17:48:36 +02:00 committed by GitHub
commit c63fe290e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 98 additions and 18 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;
@ -94,6 +95,8 @@ public:
void signalArbiter(u32 waitingAddress, s32 threadCount);
void sleepThread(s64 ns);
void sleepThreadOnArbiter(u32 waitingAddress);
void sleepThreadOnArbiterWithTimeout(u32 waitingAddress, s64 timeoutNs);
void switchThread(int newThreadIndex);
void sortThreads();
std::optional<int> getNextThread();
@ -214,6 +217,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 +258,7 @@ public:
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }
void clearInstructionCache();
void clearInstructionCacheRange(u32 start, u32 size);
void pollThreadWakeups();
u32 getSharedFontVaddr();
};

View file

@ -98,16 +98,17 @@ struct Session {
};
enum class ThreadStatus {
Running, // Currently running
Ready, // Ready to run
WaitArbiter, // Waiting on an address arbiter
WaitSleep, // Waiting due to a SleepThread SVC
WaitSync1, // Waiting for the single object in the wait list to be ready
WaitSyncAny, // Wait for one object of the many that might be in the wait list to be ready
WaitSyncAll, // Waiting for ALL sync objects in its wait list to be ready
WaitIPC, // Waiting for the reply from an IPC request
Dormant, // Created but not yet made ready
Dead // Run to completion, or forcefully terminated
Running, // Currently running
Ready, // Ready to run
WaitArbiter, // Waiting on an address arbiter
WaitArbiterTimeout, // Waiting on an address arbiter with timeout
WaitSleep, // Waiting due to a SleepThread SVC
WaitSync1, // Waiting for the single object in the wait list to be ready
WaitSyncAny, // Wait for one object of the many that might be in the wait list to be ready
WaitSyncAll, // Waiting for ALL sync objects in its wait list to be ready
WaitIPC, // Waiting for the reply from an IPC request
Dormant, // Created but not yet made ready
Dead // Run to completion, or forcefully terminated
};
struct Thread {

View file

@ -11,8 +11,9 @@ 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
Panic = 4, // Dummy event that is always pending and should never be triggered (Timestamp = UINT64_MAX)
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 = 5, // Dummy event that is always pending and should never be triggered (Timestamp = UINT64_MAX)
TotalNumberOfEvents // How many event types do we have in total?
};
static constexpr usize totalNumberOfEvents = static_cast<usize>(EventType::TotalNumberOfEvents);
@ -88,4 +89,4 @@ struct Scheduler {
return (arm11Clock * s64(ns)) / 1000000000;
}
};
};