diff options
| author | 2018-10-05 13:41:54 -0400 | |
|---|---|---|
| committer | 2018-10-05 13:41:54 -0400 | |
| commit | e51d715700a35a8f14e5b804b6f7553c9a40888b (patch) | |
| tree | 96917effcab47b089718a90851b2b203717d324a /src/core/hle/kernel/scheduler.cpp | |
| parent | Merge pull request #1442 from lioncash/format (diff) | |
| parent | kernel/thread: Make all instance variables private (diff) | |
| download | yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.tar.gz yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.tar.xz yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.zip | |
Merge pull request #1439 from lioncash/thread
kernel/thread: Make all instance variables private
Diffstat (limited to 'src/core/hle/kernel/scheduler.cpp')
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 1e82cfffb..cfd6e1bad 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -38,10 +38,10 @@ Thread* Scheduler::PopNextReadyThread() { | |||
| 38 | Thread* next = nullptr; | 38 | Thread* next = nullptr; |
| 39 | Thread* thread = GetCurrentThread(); | 39 | Thread* thread = GetCurrentThread(); |
| 40 | 40 | ||
| 41 | if (thread && thread->status == ThreadStatus::Running) { | 41 | if (thread && thread->GetStatus() == ThreadStatus::Running) { |
| 42 | // We have to do better than the current thread. | 42 | // We have to do better than the current thread. |
| 43 | // This call returns null when that's not possible. | 43 | // This call returns null when that's not possible. |
| 44 | next = ready_queue.pop_first_better(thread->current_priority); | 44 | next = ready_queue.pop_first_better(thread->GetPriority()); |
| 45 | if (!next) { | 45 | if (!next) { |
| 46 | // Otherwise just keep going with the current thread | 46 | // Otherwise just keep going with the current thread |
| 47 | next = thread; | 47 | next = thread; |
| @@ -58,22 +58,21 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 58 | 58 | ||
| 59 | // Save context for previous thread | 59 | // Save context for previous thread |
| 60 | if (previous_thread) { | 60 | if (previous_thread) { |
| 61 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); | 61 | cpu_core.SaveContext(previous_thread->GetContext()); |
| 62 | cpu_core.SaveContext(previous_thread->context); | ||
| 63 | // Save the TPIDR_EL0 system register in case it was modified. | 62 | // Save the TPIDR_EL0 system register in case it was modified. |
| 64 | previous_thread->tpidr_el0 = cpu_core.GetTPIDR_EL0(); | 63 | previous_thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0()); |
| 65 | 64 | ||
| 66 | if (previous_thread->status == ThreadStatus::Running) { | 65 | if (previous_thread->GetStatus() == ThreadStatus::Running) { |
| 67 | // This is only the case when a reschedule is triggered without the current thread | 66 | // This is only the case when a reschedule is triggered without the current thread |
| 68 | // yielding execution (i.e. an event triggered, system core time-sliced, etc) | 67 | // yielding execution (i.e. an event triggered, system core time-sliced, etc) |
| 69 | ready_queue.push_front(previous_thread->current_priority, previous_thread); | 68 | ready_queue.push_front(previous_thread->GetPriority(), previous_thread); |
| 70 | previous_thread->status = ThreadStatus::Ready; | 69 | previous_thread->SetStatus(ThreadStatus::Ready); |
| 71 | } | 70 | } |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | // Load context of new thread | 73 | // Load context of new thread |
| 75 | if (new_thread) { | 74 | if (new_thread) { |
| 76 | ASSERT_MSG(new_thread->status == ThreadStatus::Ready, | 75 | ASSERT_MSG(new_thread->GetStatus() == ThreadStatus::Ready, |
| 77 | "Thread must be ready to become running."); | 76 | "Thread must be ready to become running."); |
| 78 | 77 | ||
| 79 | // Cancel any outstanding wakeup events for this thread | 78 | // Cancel any outstanding wakeup events for this thread |
| @@ -83,15 +82,16 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 83 | 82 | ||
| 84 | current_thread = new_thread; | 83 | current_thread = new_thread; |
| 85 | 84 | ||
| 86 | ready_queue.remove(new_thread->current_priority, new_thread); | 85 | ready_queue.remove(new_thread->GetPriority(), new_thread); |
| 87 | new_thread->status = ThreadStatus::Running; | 86 | new_thread->SetStatus(ThreadStatus::Running); |
| 88 | 87 | ||
| 89 | if (previous_process != current_thread->owner_process) { | 88 | const auto thread_owner_process = current_thread->GetOwnerProcess(); |
| 90 | Core::CurrentProcess() = current_thread->owner_process; | 89 | if (previous_process != thread_owner_process) { |
| 90 | Core::CurrentProcess() = thread_owner_process; | ||
| 91 | SetCurrentPageTable(&Core::CurrentProcess()->VMManager().page_table); | 91 | SetCurrentPageTable(&Core::CurrentProcess()->VMManager().page_table); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | cpu_core.LoadContext(new_thread->context); | 94 | cpu_core.LoadContext(new_thread->GetContext()); |
| 95 | cpu_core.SetTlsAddress(new_thread->GetTLSAddress()); | 95 | cpu_core.SetTlsAddress(new_thread->GetTLSAddress()); |
| 96 | cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); | 96 | cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); |
| 97 | cpu_core.ClearExclusiveState(); | 97 | cpu_core.ClearExclusiveState(); |
| @@ -136,14 +136,14 @@ void Scheduler::RemoveThread(Thread* thread) { | |||
| 136 | void Scheduler::ScheduleThread(Thread* thread, u32 priority) { | 136 | void Scheduler::ScheduleThread(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->GetStatus() == ThreadStatus::Ready); |
| 140 | ready_queue.push_back(priority, thread); | 140 | ready_queue.push_back(priority, thread); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | void Scheduler::UnscheduleThread(Thread* thread, u32 priority) { | 143 | void Scheduler::UnscheduleThread(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 | ASSERT(thread->status == ThreadStatus::Ready); | 146 | ASSERT(thread->GetStatus() == ThreadStatus::Ready); |
| 147 | ready_queue.remove(priority, thread); | 147 | ready_queue.remove(priority, thread); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| @@ -151,8 +151,8 @@ void Scheduler::SetThreadPriority(Thread* thread, u32 priority) { | |||
| 151 | std::lock_guard<std::mutex> lock(scheduler_mutex); | 151 | std::lock_guard<std::mutex> lock(scheduler_mutex); |
| 152 | 152 | ||
| 153 | // If thread was ready, adjust queues | 153 | // If thread was ready, adjust queues |
| 154 | if (thread->status == ThreadStatus::Ready) | 154 | if (thread->GetStatus() == ThreadStatus::Ready) |
| 155 | ready_queue.move(thread, thread->current_priority, priority); | 155 | ready_queue.move(thread, thread->GetPriority(), priority); |
| 156 | else | 156 | else |
| 157 | ready_queue.prepare(priority); | 157 | ready_queue.prepare(priority); |
| 158 | } | 158 | } |