summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2021-11-28 00:40:25 -0800
committerGravatar bunnei2021-12-06 16:39:18 -0800
commit42697527ba6e981237f03f850826b5e722917414 (patch)
tree0b743ed66c4fbf306b395a83098fbf2c19fcab3a /src/core/hle/kernel
parenthle: kernel: svc: Fix deadlock that can occur with single core. (diff)
downloadyuzu-42697527ba6e981237f03f850826b5e722917414.tar.gz
yuzu-42697527ba6e981237f03f850826b5e722917414.tar.xz
yuzu-42697527ba6e981237f03f850826b5e722917414.zip
hle: kernel: k_thread: Rename sleeping_queue -> wait_queue.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/k_thread.cpp22
-rw-r--r--src/core/hle/kernel/k_thread.h8
2 files changed, 13 insertions, 17 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 334487d8a..245437387 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -161,7 +161,7 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s
161 base_priority = prio; 161 base_priority = prio;
162 162
163 // Initialize sleeping queue. 163 // Initialize sleeping queue.
164 sleeping_queue = nullptr; 164 wait_queue = nullptr;
165 165
166 // Set suspend flags. 166 // Set suspend flags.
167 suspend_request_flags = 0; 167 suspend_request_flags = 0;
@@ -333,7 +333,7 @@ void KThread::OnTimer() {
333 333
334 // If we're waiting, cancel the wait. 334 // If we're waiting, cancel the wait.
335 if (GetState() == ThreadState::Waiting) { 335 if (GetState() == ThreadState::Waiting) {
336 sleeping_queue->CancelWait(this, ResultTimedOut, false); 336 wait_queue->CancelWait(this, ResultTimedOut, false);
337 } 337 }
338} 338}
339 339
@@ -570,7 +570,7 @@ ResultCode KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) {
570 } 570 }
571 571
572 // Update the pinned waiter list. 572 // Update the pinned waiter list.
573 ThreadQueueImplForKThreadSetProperty wait_queue(kernel, std::addressof(pinned_waiter_list)); 573 ThreadQueueImplForKThreadSetProperty wait_queue_(kernel, std::addressof(pinned_waiter_list));
574 { 574 {
575 bool retry_update{}; 575 bool retry_update{};
576 do { 576 do {
@@ -605,7 +605,7 @@ ResultCode KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) {
605 605
606 // Wait until the thread isn't pinned any more. 606 // Wait until the thread isn't pinned any more.
607 pinned_waiter_list.push_back(GetCurrentThread(kernel)); 607 pinned_waiter_list.push_back(GetCurrentThread(kernel));
608 GetCurrentThread(kernel).BeginWait(std::addressof(wait_queue)); 608 GetCurrentThread(kernel).BeginWait(std::addressof(wait_queue_));
609 } else { 609 } else {
610 // If the thread isn't pinned, release the scheduler lock and retry until it's 610 // If the thread isn't pinned, release the scheduler lock and retry until it's
611 // not current. 611 // not current.
@@ -663,7 +663,7 @@ void KThread::WaitCancel() {
663 // Check if we're waiting and cancellable. 663 // Check if we're waiting and cancellable.
664 if (this->GetState() == ThreadState::Waiting && cancellable) { 664 if (this->GetState() == ThreadState::Waiting && cancellable) {
665 wait_cancelled = false; 665 wait_cancelled = false;
666 sleeping_queue->CancelWait(this, ResultCancelled, true); 666 wait_queue->CancelWait(this, ResultCancelled, true);
667 } else { 667 } else {
668 // Otherwise, note that we cancelled a wait. 668 // Otherwise, note that we cancelled a wait.
669 wait_cancelled = true; 669 wait_cancelled = true;
@@ -1002,7 +1002,7 @@ ResultCode KThread::Sleep(s64 timeout) {
1002 ASSERT(this == GetCurrentThreadPointer(kernel)); 1002 ASSERT(this == GetCurrentThreadPointer(kernel));
1003 ASSERT(timeout > 0); 1003 ASSERT(timeout > 0);
1004 1004
1005 ThreadQueueImplForKThreadSleep wait_queue(kernel); 1005 ThreadQueueImplForKThreadSleep wait_queue_(kernel);
1006 { 1006 {
1007 // Setup the scheduling lock and sleep. 1007 // Setup the scheduling lock and sleep.
1008 KScopedSchedulerLockAndSleep slp(kernel, this, timeout); 1008 KScopedSchedulerLockAndSleep slp(kernel, this, timeout);
@@ -1014,7 +1014,7 @@ ResultCode KThread::Sleep(s64 timeout) {
1014 } 1014 }
1015 1015
1016 // Wait for the sleep to end. 1016 // Wait for the sleep to end.
1017 this->BeginWait(std::addressof(wait_queue)); 1017 this->BeginWait(std::addressof(wait_queue_));
1018 SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Sleep); 1018 SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Sleep);
1019 } 1019 }
1020 1020
@@ -1026,7 +1026,7 @@ void KThread::BeginWait(KThreadQueue* queue) {
1026 SetState(ThreadState::Waiting); 1026 SetState(ThreadState::Waiting);
1027 1027
1028 // Set our wait queue. 1028 // Set our wait queue.
1029 sleeping_queue = queue; 1029 wait_queue = queue;
1030} 1030}
1031 1031
1032void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_) { 1032void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_) {
@@ -1035,7 +1035,7 @@ void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCod
1035 1035
1036 // If we're waiting, notify our queue that we're available. 1036 // If we're waiting, notify our queue that we're available.
1037 if (GetState() == ThreadState::Waiting) { 1037 if (GetState() == ThreadState::Waiting) {
1038 sleeping_queue->NotifyAvailable(this, signaled_object, wait_result_); 1038 wait_queue->NotifyAvailable(this, signaled_object, wait_result_);
1039 } 1039 }
1040} 1040}
1041 1041
@@ -1045,7 +1045,7 @@ void KThread::EndWait(ResultCode wait_result_) {
1045 1045
1046 // If we're waiting, notify our queue that we're available. 1046 // If we're waiting, notify our queue that we're available.
1047 if (GetState() == ThreadState::Waiting) { 1047 if (GetState() == ThreadState::Waiting) {
1048 sleeping_queue->EndWait(this, wait_result_); 1048 wait_queue->EndWait(this, wait_result_);
1049 } 1049 }
1050} 1050}
1051 1051
@@ -1055,7 +1055,7 @@ void KThread::CancelWait(ResultCode wait_result_, bool cancel_timer_task) {
1055 1055
1056 // If we're waiting, notify our queue that we're available. 1056 // If we're waiting, notify our queue that we're available.
1057 if (GetState() == ThreadState::Waiting) { 1057 if (GetState() == ThreadState::Waiting) {
1058 sleeping_queue->CancelWait(this, wait_result_, cancel_timer_task); 1058 wait_queue->CancelWait(this, wait_result_, cancel_timer_task);
1059 } 1059 }
1060} 1060}
1061 1061
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index 94b87bef1..c8a08bd71 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -453,10 +453,6 @@ public:
453 return per_core_priority_queue_entry[core]; 453 return per_core_priority_queue_entry[core];
454 } 454 }
455 455
456 void SetSleepingQueue(KThreadQueue* q) {
457 sleeping_queue = q;
458 }
459
460 [[nodiscard]] bool IsKernelThread() const { 456 [[nodiscard]] bool IsKernelThread() const {
461 return GetActiveCore() == 3; 457 return GetActiveCore() == 3;
462 } 458 }
@@ -604,7 +600,7 @@ public:
604 } 600 }
605 601
606 void ClearWaitQueue() { 602 void ClearWaitQueue() {
607 sleeping_queue = nullptr; 603 wait_queue = nullptr;
608 } 604 }
609 605
610 void BeginWait(KThreadQueue* queue); 606 void BeginWait(KThreadQueue* queue);
@@ -715,7 +711,7 @@ private:
715 s64 schedule_count{}; 711 s64 schedule_count{};
716 s64 last_scheduled_tick{}; 712 s64 last_scheduled_tick{};
717 std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> per_core_priority_queue_entry{}; 713 std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> per_core_priority_queue_entry{};
718 KThreadQueue* sleeping_queue{}; 714 KThreadQueue* wait_queue{};
719 WaiterList waiter_list{}; 715 WaiterList waiter_list{};
720 WaiterList pinned_waiter_list{}; 716 WaiterList pinned_waiter_list{};
721 KThread* lock_owner{}; 717 KThread* lock_owner{};