diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 47 |
1 files changed, 23 insertions, 24 deletions
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 | ||