mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 15:01:50 +01:00
Add double-insertion debug check to InsertThread
This is a cause for a large amount of scheduler bugs so we should generally check for this on debug builds as it is a fairly easy way to check for issues for some performance cost.
This commit is contained in:
parent
5694c9b34b
commit
4df3c98225
@ -95,6 +95,16 @@ namespace skyline::kernel {
|
||||
thread->scheduleCondition.wait(lock, [&]() { return !thread->isPaused; });
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Scan the queue for the same thread to prevent double insertion
|
||||
for (auto &residentThread : core.queue) {
|
||||
if (residentThread == thread) {
|
||||
Logger::Error("T{} already exists in C{}", thread->id, core.id);
|
||||
Logger::EmulationContext.Flush();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
auto nextThread{std::upper_bound(core.queue.begin(), core.queue.end(), thread->priority.load(), type::KThread::IsHigherPriority)};
|
||||
if (nextThread == core.queue.begin()) {
|
||||
if (nextThread != core.queue.end()) {
|
||||
|
Loading…
Reference in New Issue
Block a user