|
|
|
@ -516,7 +516,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
|
|
|
|
|
thread->WakeAfterDelay(nano_seconds);
|
|
|
|
|
thread->SetWakeupCallback(DefaultThreadWakeupCallback);
|
|
|
|
|
|
|
|
|
|
system.CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
|
|
|
|
|
return RESULT_TIMEOUT;
|
|
|
|
|
}
|
|
|
|
@ -534,8 +534,7 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thread->CancelWait();
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1069,8 +1068,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act
|
|
|
|
|
|
|
|
|
|
thread->SetActivity(static_cast<ThreadActivity>(activity));
|
|
|
|
|
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1152,8 +1150,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri
|
|
|
|
|
|
|
|
|
|
thread->SetPriority(priority);
|
|
|
|
|
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1509,8 +1506,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
|
|
|
|
|
thread->SetName(
|
|
|
|
|
fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle));
|
|
|
|
|
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
@ -1532,10 +1528,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) {
|
|
|
|
|
thread->ResumeFromWait();
|
|
|
|
|
|
|
|
|
|
if (thread->GetStatus() == ThreadStatus::Ready) {
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
else
|
|
|
|
|
Core::System::GetInstance().GlobalScheduler().SetReselectionPending();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
@ -1582,10 +1575,7 @@ static void SleepThread(Core::System& system, s64 nanoseconds) {
|
|
|
|
|
current_thread->Sleep(nanoseconds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reschedule all CPU cores
|
|
|
|
|
for (std::size_t i = 0; i < Core::NUM_CPU_CORES; ++i) {
|
|
|
|
|
system.CpuCore(i).PrepareReschedule();
|
|
|
|
|
}
|
|
|
|
|
system.PrepareReschedule(current_thread->GetProcessorID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Wait process wide key atomic
|
|
|
|
@ -1632,7 +1622,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add
|
|
|
|
|
|
|
|
|
|
// Note: Deliberately don't attempt to inherit the lock owner's priority.
|
|
|
|
|
|
|
|
|
|
system.CpuCore(current_thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(current_thread->GetProcessorID());
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1644,7 +1634,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
|
|
|
|
|
|
|
|
|
|
// Retrieve a list of all threads that are waiting for this condition variable.
|
|
|
|
|
std::vector<SharedPtr<Thread>> waiting_threads;
|
|
|
|
|
const auto& scheduler = Core::System::GetInstance().GlobalScheduler();
|
|
|
|
|
const auto& scheduler = system.GlobalScheduler();
|
|
|
|
|
const auto& thread_list = scheduler.GetThreadList();
|
|
|
|
|
|
|
|
|
|
for (const auto& thread : thread_list) {
|
|
|
|
@ -1706,8 +1696,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
|
|
|
|
|
thread->SetLockOwner(nullptr);
|
|
|
|
|
thread->SetMutexWaitAddress(0);
|
|
|
|
|
thread->SetWaitHandle(0);
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
} else {
|
|
|
|
|
// Atomically signal that the mutex now has a waiting thread.
|
|
|
|
|
do {
|
|
|
|
@ -1731,8 +1720,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
|
|
|
|
|
thread->SetStatus(ThreadStatus::WaitMutex);
|
|
|
|
|
|
|
|
|
|
owner->AddMutexWaiter(thread);
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1758,13 +1746,10 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto arbitration_type = static_cast<AddressArbiter::ArbitrationType>(type);
|
|
|
|
|
auto& address_arbiter =
|
|
|
|
|
system.Kernel().CurrentProcess()->GetAddressArbiter();
|
|
|
|
|
auto& address_arbiter = system.Kernel().CurrentProcess()->GetAddressArbiter();
|
|
|
|
|
ResultCode result = address_arbiter.WaitForAddress(address, arbitration_type, value, timeout);
|
|
|
|
|
if (result == RESULT_SUCCESS)
|
|
|
|
|
Core::System::GetInstance()
|
|
|
|
|
.CpuCore(GetCurrentThread()->GetProcessorID())
|
|
|
|
|
.PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2051,10 +2036,10 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle,
|
|
|
|
|
return ERR_INVALID_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
thread->ChangeCore(core, affinity_mask);
|
|
|
|
|
if (thread->GetProcessorID() >= 0)
|
|
|
|
|
Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID());
|
|
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2165,7 +2150,7 @@ static ResultCode SignalEvent(Core::System& system, Handle handle) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writable_event->Signal();
|
|
|
|
|
Core::System::GetInstance().PrepareReschedule();
|
|
|
|
|
system.PrepareReschedule();
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|