diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_session.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 47 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 28 | ||||
| -rw-r--r-- | src/core/hle/kernel/wait_object.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/debugger/wait_tree.cpp | 44 |
10 files changed, 92 insertions, 93 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index dcc68aabf..233fdab25 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp | |||
| @@ -20,7 +20,7 @@ namespace AddressArbiter { | |||
| 20 | static ResultCode WaitForAddress(VAddr address, s64 timeout) { | 20 | static ResultCode WaitForAddress(VAddr address, s64 timeout) { |
| 21 | SharedPtr<Thread> current_thread = GetCurrentThread(); | 21 | SharedPtr<Thread> current_thread = GetCurrentThread(); |
| 22 | current_thread->arb_wait_address = address; | 22 | current_thread->arb_wait_address = address; |
| 23 | current_thread->status = THREADSTATUS_WAIT_ARB; | 23 | current_thread->status = ThreadStatus::WaitArb; |
| 24 | current_thread->wakeup_callback = nullptr; | 24 | current_thread->wakeup_callback = nullptr; |
| 25 | 25 | ||
| 26 | current_thread->WakeAfterDelay(timeout); | 26 | current_thread->WakeAfterDelay(timeout); |
| @@ -65,7 +65,7 @@ static void WakeThreads(std::vector<SharedPtr<Thread>>& waiting_threads, s32 num | |||
| 65 | 65 | ||
| 66 | // Signal the waiting threads. | 66 | // Signal the waiting threads. |
| 67 | for (size_t i = 0; i < last; i++) { | 67 | for (size_t i = 0; i < last; i++) { |
| 68 | ASSERT(waiting_threads[i]->status == THREADSTATUS_WAIT_ARB); | 68 | ASSERT(waiting_threads[i]->status == ThreadStatus::WaitArb); |
| 69 | waiting_threads[i]->SetWaitSynchronizationResult(RESULT_SUCCESS); | 69 | waiting_threads[i]->SetWaitSynchronizationResult(RESULT_SUCCESS); |
| 70 | waiting_threads[i]->arb_wait_address = 0; | 70 | waiting_threads[i]->arb_wait_address = 0; |
| 71 | waiting_threads[i]->ResumeFromWait(); | 71 | waiting_threads[i]->ResumeFromWait(); |
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 8f40bdd5a..f24392520 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -38,7 +38,7 @@ SharedPtr<Event> HLERequestContext::SleepClientThread(SharedPtr<Thread> thread, | |||
| 38 | thread->wakeup_callback = | 38 | thread->wakeup_callback = |
| 39 | [context = *this, callback](ThreadWakeupReason reason, SharedPtr<Thread> thread, | 39 | [context = *this, callback](ThreadWakeupReason reason, SharedPtr<Thread> thread, |
| 40 | SharedPtr<WaitObject> object, size_t index) mutable -> bool { | 40 | SharedPtr<WaitObject> object, size_t index) mutable -> bool { |
| 41 | ASSERT(thread->status == THREADSTATUS_WAIT_HLE_EVENT); | 41 | ASSERT(thread->status == ThreadStatus::WaitHLEEvent); |
| 42 | callback(thread, context, reason); | 42 | callback(thread, context, reason); |
| 43 | context.WriteToOutgoingCommandBuffer(*thread); | 43 | context.WriteToOutgoingCommandBuffer(*thread); |
| 44 | return true; | 44 | return true; |
| @@ -50,7 +50,7 @@ SharedPtr<Event> HLERequestContext::SleepClientThread(SharedPtr<Thread> thread, | |||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | event->Clear(); | 52 | event->Clear(); |
| 53 | thread->status = THREADSTATUS_WAIT_HLE_EVENT; | 53 | thread->status = ThreadStatus::WaitHLEEvent; |
| 54 | thread->wait_objects = {event}; | 54 | thread->wait_objects = {event}; |
| 55 | event->AddWaitingThread(thread); | 55 | event->AddWaitingThread(thread); |
| 56 | 56 | ||
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 65560226d..3f1de3258 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -28,7 +28,7 @@ static std::pair<SharedPtr<Thread>, u32> GetHighestPriorityMutexWaitingThread( | |||
| 28 | if (thread->mutex_wait_address != mutex_addr) | 28 | if (thread->mutex_wait_address != mutex_addr) |
| 29 | continue; | 29 | continue; |
| 30 | 30 | ||
| 31 | ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX); | 31 | ASSERT(thread->status == ThreadStatus::WaitMutex); |
| 32 | 32 | ||
| 33 | ++num_waiters; | 33 | ++num_waiters; |
| 34 | if (highest_priority_thread == nullptr || | 34 | if (highest_priority_thread == nullptr || |
| @@ -83,7 +83,7 @@ ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle, | |||
| 83 | GetCurrentThread()->mutex_wait_address = address; | 83 | GetCurrentThread()->mutex_wait_address = address; |
| 84 | GetCurrentThread()->wait_handle = requesting_thread_handle; | 84 | GetCurrentThread()->wait_handle = requesting_thread_handle; |
| 85 | 85 | ||
| 86 | GetCurrentThread()->status = THREADSTATUS_WAIT_MUTEX; | 86 | GetCurrentThread()->status = ThreadStatus::WaitMutex; |
| 87 | GetCurrentThread()->wakeup_callback = nullptr; | 87 | GetCurrentThread()->wakeup_callback = nullptr; |
| 88 | 88 | ||
| 89 | // Update the lock holder thread's priority to prevent priority inversion. | 89 | // Update the lock holder thread's priority to prevent priority inversion. |
| @@ -121,7 +121,7 @@ ResultCode Mutex::Release(VAddr address) { | |||
| 121 | // Grant the mutex to the next waiting thread and resume it. | 121 | // Grant the mutex to the next waiting thread and resume it. |
| 122 | Memory::Write32(address, mutex_value); | 122 | Memory::Write32(address, mutex_value); |
| 123 | 123 | ||
| 124 | ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX); | 124 | ASSERT(thread->status == ThreadStatus::WaitMutex); |
| 125 | thread->ResumeFromWait(); | 125 | thread->ResumeFromWait(); |
| 126 | 126 | ||
| 127 | thread->lock_owner = nullptr; | 127 | thread->lock_owner = nullptr; |
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 1f4abfbe8..f7e25cbf5 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -34,7 +34,7 @@ Thread* Scheduler::PopNextReadyThread() { | |||
| 34 | Thread* next = nullptr; | 34 | Thread* next = nullptr; |
| 35 | Thread* thread = GetCurrentThread(); | 35 | Thread* thread = GetCurrentThread(); |
| 36 | 36 | ||
| 37 | if (thread && thread->status == THREADSTATUS_RUNNING) { | 37 | if (thread && thread->status == ThreadStatus::Running) { |
| 38 | // We have to do better than the current thread. | 38 | // We have to do better than the current thread. |
| 39 | // This call returns null when that's not possible. | 39 | // This call returns null when that's not possible. |
| 40 | next = ready_queue.pop_first_better(thread->current_priority); | 40 | next = ready_queue.pop_first_better(thread->current_priority); |
| @@ -57,17 +57,17 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 57 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); | 57 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); |
| 58 | cpu_core->SaveContext(previous_thread->context); | 58 | cpu_core->SaveContext(previous_thread->context); |
| 59 | 59 | ||
| 60 | if (previous_thread->status == THREADSTATUS_RUNNING) { | 60 | if (previous_thread->status == ThreadStatus::Running) { |
| 61 | // This is only the case when a reschedule is triggered without the current thread | 61 | // This is only the case when a reschedule is triggered without the current thread |
| 62 | // yielding execution (i.e. an event triggered, system core time-sliced, etc) | 62 | // yielding execution (i.e. an event triggered, system core time-sliced, etc) |
| 63 | ready_queue.push_front(previous_thread->current_priority, previous_thread); | 63 | ready_queue.push_front(previous_thread->current_priority, previous_thread); |
| 64 | previous_thread->status = THREADSTATUS_READY; | 64 | previous_thread->status = ThreadStatus::Ready; |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // Load context of new thread | 68 | // Load context of new thread |
| 69 | if (new_thread) { | 69 | if (new_thread) { |
| 70 | ASSERT_MSG(new_thread->status == THREADSTATUS_READY, | 70 | ASSERT_MSG(new_thread->status == ThreadStatus::Ready, |
| 71 | "Thread must be ready to become running."); | 71 | "Thread must be ready to become running."); |
| 72 | 72 | ||
| 73 | // Cancel any outstanding wakeup events for this thread | 73 | // Cancel any outstanding wakeup events for this thread |
| @@ -78,7 +78,7 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 78 | current_thread = new_thread; | 78 | current_thread = new_thread; |
| 79 | 79 | ||
| 80 | ready_queue.remove(new_thread->current_priority, new_thread); | 80 | ready_queue.remove(new_thread->current_priority, new_thread); |
| 81 | new_thread->status = THREADSTATUS_RUNNING; | 81 | new_thread->status = ThreadStatus::Running; |
| 82 | 82 | ||
| 83 | if (previous_process != current_thread->owner_process) { | 83 | if (previous_process != current_thread->owner_process) { |
| 84 | Core::CurrentProcess() = current_thread->owner_process; | 84 | Core::CurrentProcess() = current_thread->owner_process; |
| @@ -129,14 +129,14 @@ void Scheduler::RemoveThread(Thread* thread) { | |||
| 129 | void Scheduler::ScheduleThread(Thread* thread, u32 priority) { | 129 | void Scheduler::ScheduleThread(Thread* thread, u32 priority) { |
| 130 | std::lock_guard<std::mutex> lock(scheduler_mutex); | 130 | std::lock_guard<std::mutex> lock(scheduler_mutex); |
| 131 | 131 | ||
| 132 | ASSERT(thread->status == THREADSTATUS_READY); | 132 | ASSERT(thread->status == ThreadStatus::Ready); |
| 133 | ready_queue.push_back(priority, thread); | 133 | ready_queue.push_back(priority, thread); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | void Scheduler::UnscheduleThread(Thread* thread, u32 priority) { | 136 | void Scheduler::UnscheduleThread(Thread* thread, u32 priority) { |
| 137 | std::lock_guard<std::mutex> lock(scheduler_mutex); | 137 | std::lock_guard<std::mutex> lock(scheduler_mutex); |
| 138 | 138 | ||
| 139 | ASSERT(thread->status == THREADSTATUS_READY); | 139 | ASSERT(thread->status == ThreadStatus::Ready); |
| 140 | ready_queue.remove(priority, thread); | 140 | ready_queue.remove(priority, thread); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| @@ -144,7 +144,7 @@ void Scheduler::SetThreadPriority(Thread* thread, u32 priority) { | |||
| 144 | std::lock_guard<std::mutex> lock(scheduler_mutex); | 144 | std::lock_guard<std::mutex> lock(scheduler_mutex); |
| 145 | 145 | ||
| 146 | // If thread was ready, adjust queues | 146 | // If thread was ready, adjust queues |
| 147 | if (thread->status == THREADSTATUS_READY) | 147 | if (thread->status == ThreadStatus::Ready) |
| 148 | ready_queue.move(thread, thread->current_priority, priority); | 148 | ready_queue.move(thread, thread->current_priority, priority); |
| 149 | else | 149 | else |
| 150 | ready_queue.prepare(priority); | 150 | ready_queue.prepare(priority); |
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 19d17af4f..29b163528 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -110,10 +110,10 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) { | |||
| 110 | result = hle_handler->HandleSyncRequest(context); | 110 | result = hle_handler->HandleSyncRequest(context); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | if (thread->status == THREADSTATUS_RUNNING) { | 113 | if (thread->status == ThreadStatus::Running) { |
| 114 | // Put the thread to sleep until the server replies, it will be awoken in | 114 | // Put the thread to sleep until the server replies, it will be awoken in |
| 115 | // svcReplyAndReceive for LLE servers. | 115 | // svcReplyAndReceive for LLE servers. |
| 116 | thread->status = THREADSTATUS_WAIT_IPC; | 116 | thread->status = ThreadStatus::WaitIPC; |
| 117 | 117 | ||
| 118 | if (hle_handler != nullptr) { | 118 | if (hle_handler != nullptr) { |
| 119 | // For HLE services, we put the request threads to sleep for a short duration to | 119 | // For HLE services, we put the request threads to sleep for a short duration to |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index c6b0bb442..6b2995fe2 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -133,7 +133,7 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) { | |||
| 133 | /// Default thread wakeup callback for WaitSynchronization | 133 | /// Default thread wakeup callback for WaitSynchronization |
| 134 | static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread, | 134 | static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread, |
| 135 | SharedPtr<WaitObject> object, size_t index) { | 135 | SharedPtr<WaitObject> object, size_t index) { |
| 136 | ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY); | 136 | ASSERT(thread->status == ThreadStatus::WaitSynchAny); |
| 137 | 137 | ||
| 138 | if (reason == ThreadWakeupReason::Timeout) { | 138 | if (reason == ThreadWakeupReason::Timeout) { |
| 139 | thread->SetWaitSynchronizationResult(RESULT_TIMEOUT); | 139 | thread->SetWaitSynchronizationResult(RESULT_TIMEOUT); |
| @@ -197,7 +197,7 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 | |||
| 197 | object->AddWaitingThread(thread); | 197 | object->AddWaitingThread(thread); |
| 198 | 198 | ||
| 199 | thread->wait_objects = std::move(objects); | 199 | thread->wait_objects = std::move(objects); |
| 200 | thread->status = THREADSTATUS_WAIT_SYNCH_ANY; | 200 | thread->status = ThreadStatus::WaitSynchAny; |
| 201 | 201 | ||
| 202 | // Create an event to wake the thread up after the specified nanosecond delay has passed | 202 | // Create an event to wake the thread up after the specified nanosecond delay has passed |
| 203 | thread->WakeAfterDelay(nano_seconds); | 203 | thread->WakeAfterDelay(nano_seconds); |
| @@ -217,7 +217,7 @@ static ResultCode CancelSynchronization(Handle thread_handle) { | |||
| 217 | return ERR_INVALID_HANDLE; | 217 | return ERR_INVALID_HANDLE; |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY); | 220 | ASSERT(thread->status == ThreadStatus::WaitSynchAny); |
| 221 | thread->SetWaitSynchronizationResult( | 221 | thread->SetWaitSynchronizationResult( |
| 222 | ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled)); | 222 | ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled)); |
| 223 | thread->ResumeFromWait(); | 223 | thread->ResumeFromWait(); |
| @@ -468,8 +468,8 @@ static void ExitProcess() { | |||
| 468 | continue; | 468 | continue; |
| 469 | 469 | ||
| 470 | // TODO(Subv): When are the other running/ready threads terminated? | 470 | // TODO(Subv): When are the other running/ready threads terminated? |
| 471 | ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY || | 471 | ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny || |
| 472 | thread->status == THREADSTATUS_WAIT_SYNCH_ALL, | 472 | thread->status == ThreadStatus::WaitSynchAll, |
| 473 | "Exiting processes with non-waiting threads is currently unimplemented"); | 473 | "Exiting processes with non-waiting threads is currently unimplemented"); |
| 474 | 474 | ||
| 475 | thread->Stop(); | 475 | thread->Stop(); |
| @@ -545,7 +545,7 @@ static ResultCode StartThread(Handle thread_handle) { | |||
| 545 | return ERR_INVALID_HANDLE; | 545 | return ERR_INVALID_HANDLE; |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | ASSERT(thread->status == THREADSTATUS_DORMANT); | 548 | ASSERT(thread->status == ThreadStatus::Dormant); |
| 549 | 549 | ||
| 550 | thread->ResumeFromWait(); | 550 | thread->ResumeFromWait(); |
| 551 | Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); | 551 | Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); |
| @@ -596,7 +596,7 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var | |||
| 596 | current_thread->condvar_wait_address = condition_variable_addr; | 596 | current_thread->condvar_wait_address = condition_variable_addr; |
| 597 | current_thread->mutex_wait_address = mutex_addr; | 597 | current_thread->mutex_wait_address = mutex_addr; |
| 598 | current_thread->wait_handle = thread_handle; | 598 | current_thread->wait_handle = thread_handle; |
| 599 | current_thread->status = THREADSTATUS_WAIT_MUTEX; | 599 | current_thread->status = ThreadStatus::WaitMutex; |
| 600 | current_thread->wakeup_callback = nullptr; | 600 | current_thread->wakeup_callback = nullptr; |
| 601 | 601 | ||
| 602 | current_thread->WakeAfterDelay(nano_seconds); | 602 | current_thread->WakeAfterDelay(nano_seconds); |
| @@ -656,7 +656,7 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target | |||
| 656 | if (mutex_val == 0) { | 656 | if (mutex_val == 0) { |
| 657 | // We were able to acquire the mutex, resume this thread. | 657 | // We were able to acquire the mutex, resume this thread. |
| 658 | Memory::Write32(thread->mutex_wait_address, thread->wait_handle); | 658 | Memory::Write32(thread->mutex_wait_address, thread->wait_handle); |
| 659 | ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX); | 659 | ASSERT(thread->status == ThreadStatus::WaitMutex); |
| 660 | thread->ResumeFromWait(); | 660 | thread->ResumeFromWait(); |
| 661 | 661 | ||
| 662 | auto lock_owner = thread->lock_owner; | 662 | auto lock_owner = thread->lock_owner; |
| @@ -672,8 +672,8 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target | |||
| 672 | Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); | 672 | Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); |
| 673 | auto owner = g_handle_table.Get<Thread>(owner_handle); | 673 | auto owner = g_handle_table.Get<Thread>(owner_handle); |
| 674 | ASSERT(owner); | 674 | ASSERT(owner); |
| 675 | ASSERT(thread->status != THREADSTATUS_RUNNING); | 675 | ASSERT(thread->status != ThreadStatus::Running); |
| 676 | thread->status = THREADSTATUS_WAIT_MUTEX; | 676 | thread->status = ThreadStatus::WaitMutex; |
| 677 | thread->wakeup_callback = nullptr; | 677 | thread->wakeup_callback = nullptr; |
| 678 | 678 | ||
| 679 | // Signal that the mutex now has a waiting thread. | 679 | // Signal that the mutex now has a waiting thread. |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index e7fd6c842..53f2e861e 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -30,7 +30,7 @@ namespace Kernel { | |||
| 30 | static CoreTiming::EventType* ThreadWakeupEventType = nullptr; | 30 | static CoreTiming::EventType* ThreadWakeupEventType = nullptr; |
| 31 | 31 | ||
| 32 | bool Thread::ShouldWait(Thread* thread) const { | 32 | bool Thread::ShouldWait(Thread* thread) const { |
| 33 | return status != THREADSTATUS_DEAD; | 33 | return status != ThreadStatus::Dead; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | void Thread::Acquire(Thread* thread) { | 36 | void Thread::Acquire(Thread* thread) { |
| @@ -63,11 +63,11 @@ void Thread::Stop() { | |||
| 63 | 63 | ||
| 64 | // Clean up thread from ready queue | 64 | // Clean up thread from ready queue |
| 65 | // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) | 65 | // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) |
| 66 | if (status == THREADSTATUS_READY) { | 66 | if (status == ThreadStatus::Ready) { |
| 67 | scheduler->UnscheduleThread(this, current_priority); | 67 | scheduler->UnscheduleThread(this, current_priority); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | status = THREADSTATUS_DEAD; | 70 | status = ThreadStatus::Dead; |
| 71 | 71 | ||
| 72 | WakeupAllWaitingThreads(); | 72 | WakeupAllWaitingThreads(); |
| 73 | 73 | ||
| @@ -86,7 +86,7 @@ void Thread::Stop() { | |||
| 86 | 86 | ||
| 87 | void WaitCurrentThread_Sleep() { | 87 | void WaitCurrentThread_Sleep() { |
| 88 | Thread* thread = GetCurrentThread(); | 88 | Thread* thread = GetCurrentThread(); |
| 89 | thread->status = THREADSTATUS_WAIT_SLEEP; | 89 | thread->status = ThreadStatus::WaitSleep; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | void ExitCurrentThread() { | 92 | void ExitCurrentThread() { |
| @@ -110,10 +110,9 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { | |||
| 110 | 110 | ||
| 111 | bool resume = true; | 111 | bool resume = true; |
| 112 | 112 | ||
| 113 | if (thread->status == THREADSTATUS_WAIT_SYNCH_ANY || | 113 | if (thread->status == ThreadStatus::WaitSynchAny || |
| 114 | thread->status == THREADSTATUS_WAIT_SYNCH_ALL || | 114 | thread->status == ThreadStatus::WaitSynchAll || |
| 115 | thread->status == THREADSTATUS_WAIT_HLE_EVENT) { | 115 | thread->status == ThreadStatus::WaitHLEEvent) { |
| 116 | |||
| 117 | // Remove the thread from each of its waiting objects' waitlists | 116 | // Remove the thread from each of its waiting objects' waitlists |
| 118 | for (auto& object : thread->wait_objects) | 117 | for (auto& object : thread->wait_objects) |
| 119 | object->RemoveWaitingThread(thread.get()); | 118 | object->RemoveWaitingThread(thread.get()); |
| @@ -126,7 +125,7 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { | |||
| 126 | 125 | ||
| 127 | if (thread->mutex_wait_address != 0 || thread->condvar_wait_address != 0 || | 126 | if (thread->mutex_wait_address != 0 || thread->condvar_wait_address != 0 || |
| 128 | thread->wait_handle) { | 127 | thread->wait_handle) { |
| 129 | ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX); | 128 | ASSERT(thread->status == ThreadStatus::WaitMutex); |
| 130 | thread->mutex_wait_address = 0; | 129 | thread->mutex_wait_address = 0; |
| 131 | thread->condvar_wait_address = 0; | 130 | thread->condvar_wait_address = 0; |
| 132 | thread->wait_handle = 0; | 131 | thread->wait_handle = 0; |
| @@ -141,7 +140,7 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { | |||
| 141 | } | 140 | } |
| 142 | 141 | ||
| 143 | if (thread->arb_wait_address != 0) { | 142 | if (thread->arb_wait_address != 0) { |
| 144 | ASSERT(thread->status == THREADSTATUS_WAIT_ARB); | 143 | ASSERT(thread->status == ThreadStatus::WaitArb); |
| 145 | thread->arb_wait_address = 0; | 144 | thread->arb_wait_address = 0; |
| 146 | } | 145 | } |
| 147 | 146 | ||
| @@ -178,28 +177,28 @@ void Thread::ResumeFromWait() { | |||
| 178 | ASSERT_MSG(wait_objects.empty(), "Thread is waking up while waiting for objects"); | 177 | ASSERT_MSG(wait_objects.empty(), "Thread is waking up while waiting for objects"); |
| 179 | 178 | ||
| 180 | switch (status) { | 179 | switch (status) { |
| 181 | case THREADSTATUS_WAIT_SYNCH_ALL: | 180 | case ThreadStatus::WaitSynchAll: |
| 182 | case THREADSTATUS_WAIT_SYNCH_ANY: | 181 | case ThreadStatus::WaitSynchAny: |
| 183 | case THREADSTATUS_WAIT_HLE_EVENT: | 182 | case ThreadStatus::WaitHLEEvent: |
| 184 | case THREADSTATUS_WAIT_SLEEP: | 183 | case ThreadStatus::WaitSleep: |
| 185 | case THREADSTATUS_WAIT_IPC: | 184 | case ThreadStatus::WaitIPC: |
| 186 | case THREADSTATUS_WAIT_MUTEX: | 185 | case ThreadStatus::WaitMutex: |
| 187 | case THREADSTATUS_WAIT_ARB: | 186 | case ThreadStatus::WaitArb: |
| 188 | break; | 187 | break; |
| 189 | 188 | ||
| 190 | case THREADSTATUS_READY: | 189 | case ThreadStatus::Ready: |
| 191 | // The thread's wakeup callback must have already been cleared when the thread was first | 190 | // The thread's wakeup callback must have already been cleared when the thread was first |
| 192 | // awoken. | 191 | // awoken. |
| 193 | ASSERT(wakeup_callback == nullptr); | 192 | ASSERT(wakeup_callback == nullptr); |
| 194 | // If the thread is waiting on multiple wait objects, it might be awoken more than once | 193 | // If the thread is waiting on multiple wait objects, it might be awoken more than once |
| 195 | // before actually resuming. We can ignore subsequent wakeups if the thread status has | 194 | // before actually resuming. We can ignore subsequent wakeups if the thread status has |
| 196 | // already been set to THREADSTATUS_READY. | 195 | // already been set to ThreadStatus::Ready. |
| 197 | return; | 196 | return; |
| 198 | 197 | ||
| 199 | case THREADSTATUS_RUNNING: | 198 | case ThreadStatus::Running: |
| 200 | DEBUG_ASSERT_MSG(false, "Thread with object id {} has already resumed.", GetObjectId()); | 199 | DEBUG_ASSERT_MSG(false, "Thread with object id {} has already resumed.", GetObjectId()); |
| 201 | return; | 200 | return; |
| 202 | case THREADSTATUS_DEAD: | 201 | case ThreadStatus::Dead: |
| 203 | // This should never happen, as threads must complete before being stopped. | 202 | // This should never happen, as threads must complete before being stopped. |
| 204 | DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.", | 203 | DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.", |
| 205 | GetObjectId()); | 204 | GetObjectId()); |
| @@ -208,7 +207,7 @@ void Thread::ResumeFromWait() { | |||
| 208 | 207 | ||
| 209 | wakeup_callback = nullptr; | 208 | wakeup_callback = nullptr; |
| 210 | 209 | ||
| 211 | status = THREADSTATUS_READY; | 210 | status = ThreadStatus::Ready; |
| 212 | 211 | ||
| 213 | boost::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask); | 212 | boost::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask); |
| 214 | if (!new_processor_id) { | 213 | if (!new_processor_id) { |
| @@ -310,7 +309,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 310 | SharedPtr<Thread> thread(new Thread); | 309 | SharedPtr<Thread> thread(new Thread); |
| 311 | 310 | ||
| 312 | thread->thread_id = NewThreadId(); | 311 | thread->thread_id = NewThreadId(); |
| 313 | thread->status = THREADSTATUS_DORMANT; | 312 | thread->status = ThreadStatus::Dormant; |
| 314 | thread->entry_point = entry_point; | 313 | thread->entry_point = entry_point; |
| 315 | thread->stack_top = stack_top; | 314 | thread->stack_top = stack_top; |
| 316 | thread->nominal_priority = thread->current_priority = priority; | 315 | thread->nominal_priority = thread->current_priority = priority; |
| @@ -471,7 +470,7 @@ void Thread::ChangeCore(u32 core, u64 mask) { | |||
| 471 | ideal_core = core; | 470 | ideal_core = core; |
| 472 | affinity_mask = mask; | 471 | affinity_mask = mask; |
| 473 | 472 | ||
| 474 | if (status != THREADSTATUS_READY) { | 473 | if (status != ThreadStatus::Ready) { |
| 475 | return; | 474 | return; |
| 476 | } | 475 | } |
| 477 | 476 | ||
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index f1e759802..47881ec20 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -36,18 +36,18 @@ enum ThreadProcessorId : s32 { | |||
| 36 | (1 << THREADPROCESSORID_2) | (1 << THREADPROCESSORID_3) | 36 | (1 << THREADPROCESSORID_2) | (1 << THREADPROCESSORID_3) |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | enum ThreadStatus { | 39 | enum class ThreadStatus { |
| 40 | THREADSTATUS_RUNNING, ///< Currently running | 40 | Running, ///< Currently running |
| 41 | THREADSTATUS_READY, ///< Ready to run | 41 | Ready, ///< Ready to run |
| 42 | THREADSTATUS_WAIT_HLE_EVENT, ///< Waiting for hle event to finish | 42 | WaitHLEEvent, ///< Waiting for hle event to finish |
| 43 | THREADSTATUS_WAIT_SLEEP, ///< Waiting due to a SleepThread SVC | 43 | WaitSleep, ///< Waiting due to a SleepThread SVC |
| 44 | THREADSTATUS_WAIT_IPC, ///< Waiting for the reply from an IPC request | 44 | WaitIPC, ///< Waiting for the reply from an IPC request |
| 45 | THREADSTATUS_WAIT_SYNCH_ANY, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false | 45 | WaitSynchAny, ///< Waiting due to WaitSynch1 or WaitSynchN with wait_all = false |
| 46 | THREADSTATUS_WAIT_SYNCH_ALL, ///< Waiting due to WaitSynchronizationN with wait_all = true | 46 | WaitSynchAll, ///< Waiting due to WaitSynchronizationN with wait_all = true |
| 47 | THREADSTATUS_WAIT_MUTEX, ///< Waiting due to an ArbitrateLock/WaitProcessWideKey svc | 47 | WaitMutex, ///< Waiting due to an ArbitrateLock/WaitProcessWideKey svc |
| 48 | THREADSTATUS_WAIT_ARB, ///< Waiting due to a SignalToAddress/WaitForAddress svc | 48 | WaitArb, ///< Waiting due to a SignalToAddress/WaitForAddress svc |
| 49 | THREADSTATUS_DORMANT, ///< Created but not yet made ready | 49 | Dormant, ///< Created but not yet made ready |
| 50 | THREADSTATUS_DEAD ///< Run to completion, or forcefully terminated | 50 | Dead ///< Run to completion, or forcefully terminated |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | enum class ThreadWakeupReason { | 53 | enum class ThreadWakeupReason { |
| @@ -194,14 +194,14 @@ public: | |||
| 194 | * with wait_all = true. | 194 | * with wait_all = true. |
| 195 | */ | 195 | */ |
| 196 | bool IsSleepingOnWaitAll() const { | 196 | bool IsSleepingOnWaitAll() const { |
| 197 | return status == THREADSTATUS_WAIT_SYNCH_ALL; | 197 | return status == ThreadStatus::WaitSynchAll; |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | ARM_Interface::ThreadContext context; | 200 | ARM_Interface::ThreadContext context; |
| 201 | 201 | ||
| 202 | u32 thread_id; | 202 | u32 thread_id; |
| 203 | 203 | ||
| 204 | u32 status; | 204 | ThreadStatus status; |
| 205 | VAddr entry_point; | 205 | VAddr entry_point; |
| 206 | VAddr stack_top; | 206 | VAddr stack_top; |
| 207 | 207 | ||
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index b08ac72c1..eb3c92e66 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp | |||
| @@ -38,9 +38,9 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { | |||
| 38 | 38 | ||
| 39 | for (const auto& thread : waiting_threads) { | 39 | for (const auto& thread : waiting_threads) { |
| 40 | // The list of waiting threads must not contain threads that are not waiting to be awakened. | 40 | // The list of waiting threads must not contain threads that are not waiting to be awakened. |
| 41 | ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY || | 41 | ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny || |
| 42 | thread->status == THREADSTATUS_WAIT_SYNCH_ALL || | 42 | thread->status == ThreadStatus::WaitSynchAll || |
| 43 | thread->status == THREADSTATUS_WAIT_HLE_EVENT, | 43 | thread->status == ThreadStatus::WaitHLEEvent, |
| 44 | "Inconsistent thread statuses in waiting_threads"); | 44 | "Inconsistent thread statuses in waiting_threads"); |
| 45 | 45 | ||
| 46 | if (thread->current_priority >= candidate_priority) | 46 | if (thread->current_priority >= candidate_priority) |
| @@ -49,10 +49,10 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { | |||
| 49 | if (ShouldWait(thread.get())) | 49 | if (ShouldWait(thread.get())) |
| 50 | continue; | 50 | continue; |
| 51 | 51 | ||
| 52 | // A thread is ready to run if it's either in THREADSTATUS_WAIT_SYNCH_ANY or | 52 | // A thread is ready to run if it's either in ThreadStatus::WaitSynchAny or |
| 53 | // in THREADSTATUS_WAIT_SYNCH_ALL and the rest of the objects it is waiting on are ready. | 53 | // in ThreadStatus::WaitSynchAll and the rest of the objects it is waiting on are ready. |
| 54 | bool ready_to_run = true; | 54 | bool ready_to_run = true; |
| 55 | if (thread->status == THREADSTATUS_WAIT_SYNCH_ALL) { | 55 | if (thread->status == ThreadStatus::WaitSynchAll) { |
| 56 | ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), | 56 | ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), |
| 57 | [&thread](const SharedPtr<WaitObject>& object) { | 57 | [&thread](const SharedPtr<WaitObject>& object) { |
| 58 | return object->ShouldWait(thread.get()); | 58 | return object->ShouldWait(thread.get()); |
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 7101b381e..8f24586ce 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp | |||
| @@ -194,32 +194,32 @@ QString WaitTreeThread::GetText() const { | |||
| 194 | const auto& thread = static_cast<const Kernel::Thread&>(object); | 194 | const auto& thread = static_cast<const Kernel::Thread&>(object); |
| 195 | QString status; | 195 | QString status; |
| 196 | switch (thread.status) { | 196 | switch (thread.status) { |
| 197 | case THREADSTATUS_RUNNING: | 197 | case ThreadStatus::Running: |
| 198 | status = tr("running"); | 198 | status = tr("running"); |
| 199 | break; | 199 | break; |
| 200 | case THREADSTATUS_READY: | 200 | case ThreadStatus::Ready: |
| 201 | status = tr("ready"); | 201 | status = tr("ready"); |
| 202 | break; | 202 | break; |
| 203 | case THREADSTATUS_WAIT_HLE_EVENT: | 203 | case ThreadStatus::WaitHLEEvent: |
| 204 | status = tr("waiting for HLE return"); | 204 | status = tr("waiting for HLE return"); |
| 205 | break; | 205 | break; |
| 206 | case THREADSTATUS_WAIT_SLEEP: | 206 | case ThreadStatus::WaitSleep: |
| 207 | status = tr("sleeping"); | 207 | status = tr("sleeping"); |
| 208 | break; | 208 | break; |
| 209 | case THREADSTATUS_WAIT_SYNCH_ALL: | 209 | case ThreadStatus::WaitSynchAll: |
| 210 | case THREADSTATUS_WAIT_SYNCH_ANY: | 210 | case ThreadStatus::WaitSynchAny: |
| 211 | status = tr("waiting for objects"); | 211 | status = tr("waiting for objects"); |
| 212 | break; | 212 | break; |
| 213 | case THREADSTATUS_WAIT_MUTEX: | 213 | case ThreadStatus::WaitMutex: |
| 214 | status = tr("waiting for mutex"); | 214 | status = tr("waiting for mutex"); |
| 215 | break; | 215 | break; |
| 216 | case THREADSTATUS_WAIT_ARB: | 216 | case ThreadStatus::WaitArb: |
| 217 | status = tr("waiting for address arbiter"); | 217 | status = tr("waiting for address arbiter"); |
| 218 | break; | 218 | break; |
| 219 | case THREADSTATUS_DORMANT: | 219 | case ThreadStatus::Dormant: |
| 220 | status = tr("dormant"); | 220 | status = tr("dormant"); |
| 221 | break; | 221 | break; |
| 222 | case THREADSTATUS_DEAD: | 222 | case ThreadStatus::Dead: |
| 223 | status = tr("dead"); | 223 | status = tr("dead"); |
| 224 | break; | 224 | break; |
| 225 | } | 225 | } |
| @@ -232,22 +232,22 @@ QString WaitTreeThread::GetText() const { | |||
| 232 | QColor WaitTreeThread::GetColor() const { | 232 | QColor WaitTreeThread::GetColor() const { |
| 233 | const auto& thread = static_cast<const Kernel::Thread&>(object); | 233 | const auto& thread = static_cast<const Kernel::Thread&>(object); |
| 234 | switch (thread.status) { | 234 | switch (thread.status) { |
| 235 | case THREADSTATUS_RUNNING: | 235 | case ThreadStatus::Running: |
| 236 | return QColor(Qt::GlobalColor::darkGreen); | 236 | return QColor(Qt::GlobalColor::darkGreen); |
| 237 | case THREADSTATUS_READY: | 237 | case ThreadStatus::Ready: |
| 238 | return QColor(Qt::GlobalColor::darkBlue); | 238 | return QColor(Qt::GlobalColor::darkBlue); |
| 239 | case THREADSTATUS_WAIT_HLE_EVENT: | 239 | case ThreadStatus::WaitHLEEvent: |
| 240 | return QColor(Qt::GlobalColor::darkRed); | 240 | return QColor(Qt::GlobalColor::darkRed); |
| 241 | case THREADSTATUS_WAIT_SLEEP: | 241 | case ThreadStatus::WaitSleep: |
| 242 | return QColor(Qt::GlobalColor::darkYellow); | 242 | return QColor(Qt::GlobalColor::darkYellow); |
| 243 | case THREADSTATUS_WAIT_SYNCH_ALL: | 243 | case ThreadStatus::WaitSynchAll: |
| 244 | case THREADSTATUS_WAIT_SYNCH_ANY: | 244 | case ThreadStatus::WaitSynchAny: |
| 245 | case THREADSTATUS_WAIT_MUTEX: | 245 | case ThreadStatus::WaitMutex: |
| 246 | case THREADSTATUS_WAIT_ARB: | 246 | case ThreadStatus::WaitArb: |
| 247 | return QColor(Qt::GlobalColor::red); | 247 | return QColor(Qt::GlobalColor::red); |
| 248 | case THREADSTATUS_DORMANT: | 248 | case ThreadStatus::Dormant: |
| 249 | return QColor(Qt::GlobalColor::darkCyan); | 249 | return QColor(Qt::GlobalColor::darkCyan); |
| 250 | case THREADSTATUS_DEAD: | 250 | case ThreadStatus::Dead: |
| 251 | return QColor(Qt::GlobalColor::gray); | 251 | return QColor(Qt::GlobalColor::gray); |
| 252 | default: | 252 | default: |
| 253 | return WaitTreeItem::GetColor(); | 253 | return WaitTreeItem::GetColor(); |
| @@ -291,8 +291,8 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const { | |||
| 291 | else | 291 | else |
| 292 | list.push_back(std::make_unique<WaitTreeText>(tr("not waiting for mutex"))); | 292 | list.push_back(std::make_unique<WaitTreeText>(tr("not waiting for mutex"))); |
| 293 | 293 | ||
| 294 | if (thread.status == THREADSTATUS_WAIT_SYNCH_ANY || | 294 | if (thread.status == ThreadStatus::WaitSynchAny || |
| 295 | thread.status == THREADSTATUS_WAIT_SYNCH_ALL) { | 295 | thread.status == ThreadStatus::WaitSynchAll) { |
| 296 | list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects, | 296 | list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects, |
| 297 | thread.IsSleepingOnWaitAll())); | 297 | thread.IsSleepingOnWaitAll())); |
| 298 | } | 298 | } |