summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2019-03-30 19:59:10 -0400
committerGravatar GitHub2019-03-30 19:59:10 -0400
commitba3d95e5509585daadc45a466fcf0ee18a2d8e29 (patch)
treed0f667d419f516bd8fe12da39f8d10ac39664392
parentMerge pull request #2307 from lioncash/regnames (diff)
parentkernel/scheduler: Remove unused parameter to AddThread() (diff)
downloadyuzu-ba3d95e5509585daadc45a466fcf0ee18a2d8e29.tar.gz
yuzu-ba3d95e5509585daadc45a466fcf0ee18a2d8e29.tar.xz
yuzu-ba3d95e5509585daadc45a466fcf0ee18a2d8e29.zip
Merge pull request #2308 from lioncash/deduction
kernel/scheduler: Minor tidying up
-rw-r--r--src/core/hle/kernel/scheduler.cpp18
-rw-r--r--src/core/hle/kernel/scheduler.h2
-rw-r--r--src/core/hle/kernel/thread.cpp4
3 files changed, 12 insertions, 12 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 6d0f13ecf..ac501bf7f 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -29,7 +29,7 @@ Scheduler::~Scheduler() {
29} 29}
30 30
31bool Scheduler::HaveReadyThreads() const { 31bool Scheduler::HaveReadyThreads() const {
32 std::lock_guard<std::mutex> lock(scheduler_mutex); 32 std::lock_guard lock{scheduler_mutex};
33 return !ready_queue.empty(); 33 return !ready_queue.empty();
34} 34}
35 35
@@ -132,7 +132,7 @@ void Scheduler::UpdateLastContextSwitchTime(Thread* thread, Process* process) {
132} 132}
133 133
134void Scheduler::Reschedule() { 134void Scheduler::Reschedule() {
135 std::lock_guard<std::mutex> lock(scheduler_mutex); 135 std::lock_guard lock{scheduler_mutex};
136 136
137 Thread* cur = GetCurrentThread(); 137 Thread* cur = GetCurrentThread();
138 Thread* next = PopNextReadyThread(); 138 Thread* next = PopNextReadyThread();
@@ -148,35 +148,35 @@ void Scheduler::Reschedule() {
148 SwitchContext(next); 148 SwitchContext(next);
149} 149}
150 150
151void Scheduler::AddThread(SharedPtr<Thread> thread, u32 priority) { 151void Scheduler::AddThread(SharedPtr<Thread> thread) {
152 std::lock_guard<std::mutex> lock(scheduler_mutex); 152 std::lock_guard lock{scheduler_mutex};
153 153
154 thread_list.push_back(std::move(thread)); 154 thread_list.push_back(std::move(thread));
155} 155}
156 156
157void Scheduler::RemoveThread(Thread* thread) { 157void Scheduler::RemoveThread(Thread* thread) {
158 std::lock_guard<std::mutex> lock(scheduler_mutex); 158 std::lock_guard lock{scheduler_mutex};
159 159
160 thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), 160 thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread),
161 thread_list.end()); 161 thread_list.end());
162} 162}
163 163
164void Scheduler::ScheduleThread(Thread* thread, u32 priority) { 164void Scheduler::ScheduleThread(Thread* thread, u32 priority) {
165 std::lock_guard<std::mutex> lock(scheduler_mutex); 165 std::lock_guard lock{scheduler_mutex};
166 166
167 ASSERT(thread->GetStatus() == ThreadStatus::Ready); 167 ASSERT(thread->GetStatus() == ThreadStatus::Ready);
168 ready_queue.add(thread, priority); 168 ready_queue.add(thread, priority);
169} 169}
170 170
171void Scheduler::UnscheduleThread(Thread* thread, u32 priority) { 171void Scheduler::UnscheduleThread(Thread* thread, u32 priority) {
172 std::lock_guard<std::mutex> lock(scheduler_mutex); 172 std::lock_guard lock{scheduler_mutex};
173 173
174 ASSERT(thread->GetStatus() == ThreadStatus::Ready); 174 ASSERT(thread->GetStatus() == ThreadStatus::Ready);
175 ready_queue.remove(thread, priority); 175 ready_queue.remove(thread, priority);
176} 176}
177 177
178void Scheduler::SetThreadPriority(Thread* thread, u32 priority) { 178void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
179 std::lock_guard<std::mutex> lock(scheduler_mutex); 179 std::lock_guard lock{scheduler_mutex};
180 if (thread->GetPriority() == priority) { 180 if (thread->GetPriority() == priority) {
181 return; 181 return;
182 } 182 }
@@ -187,7 +187,7 @@ void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
187} 187}
188 188
189Thread* Scheduler::GetNextSuggestedThread(u32 core, u32 maximum_priority) const { 189Thread* Scheduler::GetNextSuggestedThread(u32 core, u32 maximum_priority) const {
190 std::lock_guard<std::mutex> lock(scheduler_mutex); 190 std::lock_guard lock{scheduler_mutex};
191 191
192 const u32 mask = 1U << core; 192 const u32 mask = 1U << core;
193 for (auto* thread : ready_queue) { 193 for (auto* thread : ready_queue) {
diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h
index 44baeb713..b29bf7be8 100644
--- a/src/core/hle/kernel/scheduler.h
+++ b/src/core/hle/kernel/scheduler.h
@@ -38,7 +38,7 @@ public:
38 u64 GetLastContextSwitchTicks() const; 38 u64 GetLastContextSwitchTicks() const;
39 39
40 /// Adds a new thread to the scheduler 40 /// Adds a new thread to the scheduler
41 void AddThread(SharedPtr<Thread> thread, u32 priority); 41 void AddThread(SharedPtr<Thread> thread);
42 42
43 /// Removes a thread from the scheduler 43 /// Removes a thread from the scheduler
44 void RemoveThread(Thread* thread); 44 void RemoveThread(Thread* thread);
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index e5853c46f..fa3ac3abc 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -199,7 +199,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
199 thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap(); 199 thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap();
200 thread->owner_process = &owner_process; 200 thread->owner_process = &owner_process;
201 thread->scheduler = &system.Scheduler(processor_id); 201 thread->scheduler = &system.Scheduler(processor_id);
202 thread->scheduler->AddThread(thread, priority); 202 thread->scheduler->AddThread(thread);
203 thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread); 203 thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread);
204 204
205 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used 205 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
@@ -352,7 +352,7 @@ void Thread::ChangeScheduler() {
352 if (*new_processor_id != processor_id) { 352 if (*new_processor_id != processor_id) {
353 // Remove thread from previous core's scheduler 353 // Remove thread from previous core's scheduler
354 scheduler->RemoveThread(this); 354 scheduler->RemoveThread(this);
355 next_scheduler.AddThread(this, current_priority); 355 next_scheduler.AddThread(this);
356 } 356 }
357 357
358 processor_id = *new_processor_id; 358 processor_id = *new_processor_id;