mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-04 03:04:48 +12:00
Starting on sync object rewrite #3
This commit is contained in:
parent
517d1abee8
commit
c6c45408fe
4 changed files with 43 additions and 4 deletions
src/core/kernel
|
@ -111,6 +111,10 @@ void Kernel::waitSynchronization1() {
|
|||
t.sleepTick = cpu.getTicks();
|
||||
t.waitingNanoseconds = ns;
|
||||
t.waitList[0] = handle;
|
||||
|
||||
// Add the current thread to the object's wait list
|
||||
object->getWaitlist() |= (1ull << currentThreadIndex);
|
||||
|
||||
switchToNextThread();
|
||||
}
|
||||
}
|
||||
|
@ -148,8 +152,12 @@ void Kernel::waitSynchronizationN() {
|
|||
}
|
||||
|
||||
if (!isWaitable(object)) [[unlikely]] {
|
||||
//Helpers::panic("Tried to wait on a non waitable object. Type: %s, handle: %X\n", object->getTypeName(), handle);
|
||||
Helpers::panic("Tried to wait on a non waitable object in WaitSyncN. Type: %s, handle: %X\n",
|
||||
object->getTypeName(), handle);
|
||||
}
|
||||
|
||||
// Add the current thread to the object's wait list
|
||||
object->getWaitlist() |= (1ull << currentThreadIndex);
|
||||
}
|
||||
|
||||
regs[0] = SVCResult::Success;
|
||||
|
|
|
@ -111,6 +111,7 @@ void Kernel::reset() {
|
|||
for (auto& t : threads) {
|
||||
t.status = ThreadStatus::Dead;
|
||||
t.waitList.clear();
|
||||
t.threadsWaitingForTermination = 0; // No threads are waiting for this thread to terminate cause it's dead
|
||||
}
|
||||
|
||||
for (auto& object : objects) {
|
||||
|
|
|
@ -147,6 +147,7 @@ Handle Kernel::makeThread(u32 entrypoint, u32 initialSP, u32 priority, s32 id, u
|
|||
t.status = status;
|
||||
t.handle = ret;
|
||||
t.waitingAddress = 0;
|
||||
t.threadsWaitingForTermination = 0; // Thread just spawned, no other threads waiting for it to terminate
|
||||
|
||||
t.cpsr = CPSR::UserMode | (isThumb ? CPSR::Thumb : 0);
|
||||
t.fpscr = FPSCR::ThreadDefault;
|
||||
|
@ -310,6 +311,10 @@ void Kernel::exitThread() {
|
|||
t.status = ThreadStatus::Dead;
|
||||
aliveThreadCount--;
|
||||
|
||||
// Check if any threads are sleeping, waiting for this thread to terminate, and wake them up
|
||||
if (t.threadsWaitingForTermination != 0)
|
||||
Helpers::panic("TODO: Implement threads sleeping until another thread terminates");
|
||||
|
||||
switchToNextThread();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue