mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
[Kernel] Implement thread sleeping
This commit is contained in:
parent
db0adc55c1
commit
2a4709dcfa
6 changed files with 60 additions and 7 deletions
|
@ -107,6 +107,8 @@ class CPU {
|
|||
Memory& mem;
|
||||
|
||||
public:
|
||||
static constexpr u64 ticksPerSec = 268111856;
|
||||
|
||||
CPU(Memory& mem, Kernel& kernel);
|
||||
void reset();
|
||||
|
||||
|
@ -161,7 +163,7 @@ public:
|
|||
}
|
||||
|
||||
void runFrame() {
|
||||
env.ticksLeft = 268111856 / 60;
|
||||
env.ticksLeft = ticksPerSec / 60;
|
||||
|
||||
const auto exitReason = jit->Run();
|
||||
if (static_cast<u32>(exitReason) != 0) [[unlikely]] {
|
||||
|
|
|
@ -66,6 +66,7 @@ class Kernel {
|
|||
Handle makeThread(u32 entrypoint, u32 initialSP, u32 priority, s32 id, u32 arg,ThreadStatus status = ThreadStatus::Dormant);
|
||||
|
||||
void signalArbiter(u32 waitingAddress, s32 threadCount);
|
||||
void sleepThread(s64 ns);
|
||||
void sleepThreadOnArbiter(u32 waitingAddress);
|
||||
void switchThread(int newThreadIndex);
|
||||
void sortThreads();
|
||||
|
@ -116,6 +117,7 @@ class Kernel {
|
|||
void sendSyncRequest();
|
||||
void signalEvent();
|
||||
void svcCloseHandle();
|
||||
void svcSleepThread();
|
||||
void connectToPort();
|
||||
void outputDebugString();
|
||||
void waitSynchronization1();
|
||||
|
|
|
@ -116,6 +116,11 @@ struct Thread {
|
|||
// The waiting address for threads that are waiting on an AddressArbiter
|
||||
u32 waitingAddress;
|
||||
|
||||
// The nanoseconds until a thread wakes up from being asleep or from timing out while waiting on an arbiter
|
||||
s64 waitingNanoseconds;
|
||||
// The tick this thread went to sleep on
|
||||
u64 sleepTick;
|
||||
|
||||
// Thread context used for switching between threads
|
||||
std::array<u32, 16> gprs;
|
||||
std::array<u32, 32> fprs; // Stored as u32 because dynarmic does it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue