mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-26 08:40:16 +12:00
Thread bonk part 1: Better rescheduling maybe
This commit is contained in:
parent
0ab1d6a0cc
commit
8dd5b990be
4 changed files with 48 additions and 42 deletions
src/core/kernel
|
@ -48,7 +48,7 @@ bool Kernel::signalEvent(Handle handle) {
|
|||
// We must reschedule our threads if we signalled one. Some games such as FE: Awakening rely on this
|
||||
// If this does not happen, we can have phenomena such as a thread waiting up a higher priority thread,
|
||||
// and the higher priority thread just never running
|
||||
rescheduleThreads();
|
||||
requireReschedule();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -121,7 +121,6 @@ void Kernel::waitSynchronization1() {
|
|||
if (!shouldWaitOnObject(object)) {
|
||||
acquireSyncObject(object, threads[currentThreadIndex]); // Acquire the object since it's ready
|
||||
regs[0] = Result::Success;
|
||||
rescheduleThreads();
|
||||
} else {
|
||||
// Timeout is 0, don't bother waiting, instantly timeout
|
||||
if (ns == 0) {
|
||||
|
@ -141,7 +140,7 @@ void Kernel::waitSynchronization1() {
|
|||
// Add the current thread to the object's wait list
|
||||
object->getWaitlist() |= (1ull << currentThreadIndex);
|
||||
|
||||
switchToNextThread();
|
||||
requireReschedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,14 +203,13 @@ void Kernel::waitSynchronizationN() {
|
|||
|
||||
auto& t = threads[currentThreadIndex];
|
||||
|
||||
// We only need to wait on one object. Easy...?!
|
||||
// We only need to wait on one object. Easy.
|
||||
if (!waitAll) {
|
||||
// If there's ready objects, acquire the first one and return
|
||||
if (oneObjectReady) {
|
||||
regs[0] = Result::Success;
|
||||
regs[1] = firstReadyObjectIndex; // Return index of the acquired object
|
||||
acquireSyncObject(waitObjects[firstReadyObjectIndex].second, t); // Acquire object
|
||||
rescheduleThreads();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -229,7 +227,7 @@ void Kernel::waitSynchronizationN() {
|
|||
waitObjects[i].second->getWaitlist() |= (1ull << currentThreadIndex); // And add the thread to the object's waitlist
|
||||
}
|
||||
|
||||
switchToNextThread();
|
||||
requireReschedule();
|
||||
} else {
|
||||
Helpers::panic("WaitSynchronizatioN with waitAll");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue