[Kernel] Implement ArbitrationType::DecrementAndWaitIfLess
This commit is contained in:
@@ -58,7 +58,7 @@ void Kernel::arbitrateAddress() {
|
||||
regs[0] = SVCResult::Success;
|
||||
|
||||
switch (static_cast<ArbitrationType>(type)) {
|
||||
// Puts this thread to sleep if word < value until another thread signals the address with the type SIGNAL
|
||||
// Puts this thread to sleep if word < value until another thread arbitrates the address using SIGNAL
|
||||
case ArbitrationType::WaitIfLess: {
|
||||
s32 word = static_cast<s32>(mem.read32(address)); // Yes this is meant to be signed
|
||||
if (word < value) {
|
||||
@@ -67,6 +67,17 @@ void Kernel::arbitrateAddress() {
|
||||
break;
|
||||
}
|
||||
|
||||
// Puts this thread to sleep if word < value until another thread arbitrates the address using SIGNAL
|
||||
// If the thread is put to sleep, the arbiter address is decremented
|
||||
case ArbitrationType::DecrementAndWaitIfLess: {
|
||||
s32 word = static_cast<s32>(mem.read32(address)); // Yes this is meant to be signed
|
||||
if (word < value) {
|
||||
mem.write32(address, word - 1);
|
||||
sleepThreadOnArbiter(address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ArbitrationType::Signal:
|
||||
signalArbiter(address, value);
|
||||
break;
|
||||
|
||||
@@ -73,8 +73,7 @@ void Kernel::waitSynchronizationN() {
|
||||
logSVC("WaitSynchronizationN (STUBBED)\n");
|
||||
regs[0] = SVCResult::Success;
|
||||
|
||||
if (currentThreadIndex == 1) {
|
||||
printf("WaitSynchN OoT hack triggered\n");
|
||||
switchThread(0);
|
||||
}
|
||||
printf("Hacky WaitSync stuff for OoT triggered!!!\n");
|
||||
threads[currentThreadIndex].status = ThreadStatus::Ready;
|
||||
switchThread(rand() % threadCount);
|
||||
}
|
||||
Reference in New Issue
Block a user