|
|
@ -146,61 +146,34 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32
|
|
|
|
// Perform signaling.
|
|
|
|
// Perform signaling.
|
|
|
|
s32 num_waiters{};
|
|
|
|
s32 num_waiters{};
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KScopedSchedulerLock sl(kernel);
|
|
|
|
[[maybe_unused]] const KScopedSchedulerLock sl(kernel);
|
|
|
|
|
|
|
|
|
|
|
|
auto it = thread_tree.nfind_light({addr, -1});
|
|
|
|
auto it = thread_tree.nfind_light({addr, -1});
|
|
|
|
// Determine the updated value.
|
|
|
|
// Determine the updated value.
|
|
|
|
s32 new_value{};
|
|
|
|
s32 new_value{};
|
|
|
|
if (/*GetTargetFirmware() >= TargetFirmware_7_0_0*/ true) {
|
|
|
|
if (count <= 0) {
|
|
|
|
if (count <= 0) {
|
|
|
|
if (it != thread_tree.end() && it->GetAddressArbiterKey() == addr) {
|
|
|
|
if ((it != thread_tree.end()) && (it->GetAddressArbiterKey() == addr)) {
|
|
|
|
new_value = value - 2;
|
|
|
|
new_value = value - 2;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
new_value = value + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ((it != thread_tree.end()) && (it->GetAddressArbiterKey() == addr)) {
|
|
|
|
new_value = value + 1;
|
|
|
|
auto tmp_it = it;
|
|
|
|
|
|
|
|
s32 tmp_num_waiters{};
|
|
|
|
|
|
|
|
while ((++tmp_it != thread_tree.end()) &&
|
|
|
|
|
|
|
|
(tmp_it->GetAddressArbiterKey() == addr)) {
|
|
|
|
|
|
|
|
if ((tmp_num_waiters++) >= count) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tmp_num_waiters < count) {
|
|
|
|
|
|
|
|
new_value = value - 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
new_value = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
new_value = value + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (count <= 0) {
|
|
|
|
if (it != thread_tree.end() && it->GetAddressArbiterKey() == addr) {
|
|
|
|
if ((it != thread_tree.end()) && (it->GetAddressArbiterKey() == addr)) {
|
|
|
|
|
|
|
|
new_value = value - 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
new_value = value + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
auto tmp_it = it;
|
|
|
|
auto tmp_it = it;
|
|
|
|
s32 tmp_num_waiters{};
|
|
|
|
s32 tmp_num_waiters{};
|
|
|
|
while ((tmp_it != thread_tree.end()) && (tmp_it->GetAddressArbiterKey() == addr) &&
|
|
|
|
while (++tmp_it != thread_tree.end() && tmp_it->GetAddressArbiterKey() == addr) {
|
|
|
|
(tmp_num_waiters < count + 1)) {
|
|
|
|
if (tmp_num_waiters++ >= count) {
|
|
|
|
++tmp_num_waiters;
|
|
|
|
break;
|
|
|
|
++tmp_it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (tmp_num_waiters == 0) {
|
|
|
|
if (tmp_num_waiters < count) {
|
|
|
|
new_value = value + 1;
|
|
|
|
|
|
|
|
} else if (tmp_num_waiters <= count) {
|
|
|
|
|
|
|
|
new_value = value - 1;
|
|
|
|
new_value = value - 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
new_value = value;
|
|
|
|
new_value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
new_value = value + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|