mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-09 02:40:07 +00:00
Kernel: Correct Cancel Synchronization.
This commit corrects the behavior of cancel synchronization when the thread is running/ready and ensures the next wait is cancelled as it's suppose to.
This commit is contained in:
parent
bb31df62bb
commit
7d16b2d2dd
3 changed files with 19 additions and 2 deletions
|
@ -505,6 +505,11 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
|
||||||
return RESULT_TIMEOUT;
|
return RESULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (thread->IsSyncCancelled()) {
|
||||||
|
thread->SetSyncCancelled(false);
|
||||||
|
return ERR_SYNCHRONIZATION_CANCELED;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& object : objects) {
|
for (auto& object : objects) {
|
||||||
object->AddWaitingThread(thread);
|
object->AddWaitingThread(thread);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,8 +132,11 @@ void Thread::ResumeFromWait() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::CancelWait() {
|
void Thread::CancelWait() {
|
||||||
ASSERT(GetStatus() == ThreadStatus::WaitSynch);
|
if (GetSchedulingStatus() != ThreadSchedStatus::Paused) {
|
||||||
ClearWaitObjects();
|
is_sync_cancelled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
is_sync_cancelled = false;
|
||||||
SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED);
|
SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED);
|
||||||
ResumeFromWait();
|
ResumeFromWait();
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,6 +440,14 @@ public:
|
||||||
is_running = value;
|
is_running = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsSyncCancelled() const {
|
||||||
|
return is_sync_cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSyncCancelled(bool value) {
|
||||||
|
is_sync_cancelled = value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Thread(KernelCore& kernel);
|
explicit Thread(KernelCore& kernel);
|
||||||
~Thread() override;
|
~Thread() override;
|
||||||
|
@ -524,6 +532,7 @@ private:
|
||||||
|
|
||||||
u32 scheduling_state = 0;
|
u32 scheduling_state = 0;
|
||||||
bool is_running = false;
|
bool is_running = false;
|
||||||
|
bool is_sync_cancelled = false;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue