summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar Subv2017-01-04 12:48:13 -0500
committerGravatar Subv2017-01-05 09:40:18 -0500
commitdda4ec93bea089e3286e9a965378d9411f480acd (patch)
tree29b3fcb87e02fc92e514e28877b588f09264c026 /src/core/hle/kernel/kernel.cpp
parentKernel: Remove a thread from all of its waiting objects' waiting_threads list... (diff)
downloadyuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.gz
yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.tar.xz
yuzu-dda4ec93bea089e3286e9a965378d9411f480acd.zip
Kernel: Add some asserts to enforce the invariants in the scheduler.
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 47d4df69c..f599916f0 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -27,6 +27,9 @@ void WaitObject::AddWaitingThread(SharedPtr<Thread> thread) {
27 27
28void WaitObject::RemoveWaitingThread(Thread* thread) { 28void WaitObject::RemoveWaitingThread(Thread* thread) {
29 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); 29 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
30 // If a thread passed multiple handles to the same object,
31 // the kernel might attempt to remove the thread from the object's
32 // waiting threads list multiple times.
30 if (itr != waiting_threads.end()) 33 if (itr != waiting_threads.end())
31 waiting_threads.erase(itr); 34 waiting_threads.erase(itr);
32} 35}
@@ -36,6 +39,11 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
36 s32 candidate_priority = THREADPRIO_LOWEST + 1; 39 s32 candidate_priority = THREADPRIO_LOWEST + 1;
37 40
38 for (const auto& thread : waiting_threads) { 41 for (const auto& thread : waiting_threads) {
42 // The list of waiting threads must not contain threads that are not waiting to be awakened.
43 ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY ||
44 thread->status == THREADSTATUS_WAIT_SYNCH_ALL,
45 "Inconsistent thread statuses in waiting_threads");
46
39 if (thread->current_priority >= candidate_priority) 47 if (thread->current_priority >= candidate_priority)
40 continue; 48 continue;
41 49