[Kernel] Implement ArbitrationType::DecrementAndWaitIfLess

This commit is contained in:
wheremyfoodat 2022-10-10 16:57:33 +03:00
parent 81b0f3dde0
commit 6c3acda34e
3 changed files with 16 additions and 6 deletions

View file

@ -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;