summaryrefslogtreecommitdiff
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-03-03 15:50:38 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:23 -0400
commit07993ac8c8c66bbf638dddc7750106f6dfb0e09b (patch)
treedae8c8249f66657e232dc2620489d237e17459c8 /src/core/core_timing.cpp
parentKernel: Correct Signal on Thread Death and Setup Sync Objects on Thread for D... (diff)
downloadyuzu-07993ac8c8c66bbf638dddc7750106f6dfb0e09b.tar.gz
yuzu-07993ac8c8c66bbf638dddc7750106f6dfb0e09b.tar.xz
yuzu-07993ac8c8c66bbf638dddc7750106f6dfb0e09b.zip
Kernel: Corrections to Scheduling.
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 5a7abcfca..c91ae9975 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -154,7 +154,7 @@ void CoreTiming::RemoveEvent(const std::shared_ptr<EventType>& event_type) {
154 basic_lock.unlock(); 154 basic_lock.unlock();
155} 155}
156 156
157std::optional<u64> CoreTiming::Advance() { 157std::optional<s64> CoreTiming::Advance() {
158 advance_lock.lock(); 158 advance_lock.lock();
159 basic_lock.lock(); 159 basic_lock.lock();
160 global_timer = GetGlobalTimeNs().count(); 160 global_timer = GetGlobalTimeNs().count();
@@ -170,10 +170,11 @@ std::optional<u64> CoreTiming::Advance() {
170 } 170 }
171 171
172 basic_lock.lock(); 172 basic_lock.lock();
173 global_timer = GetGlobalTimeNs().count();
173 } 174 }
174 175
175 if (!event_queue.empty()) { 176 if (!event_queue.empty()) {
176 const u64 next_time = event_queue.front().time - global_timer; 177 const s64 next_time = event_queue.front().time - global_timer;
177 basic_lock.unlock(); 178 basic_lock.unlock();
178 advance_lock.unlock(); 179 advance_lock.unlock();
179 return next_time; 180 return next_time;
@@ -191,8 +192,10 @@ void CoreTiming::ThreadLoop() {
191 paused_set = false; 192 paused_set = false;
192 const auto next_time = Advance(); 193 const auto next_time = Advance();
193 if (next_time) { 194 if (next_time) {
194 std::chrono::nanoseconds next_time_ns = std::chrono::nanoseconds(*next_time); 195 if (*next_time > 0) {
195 event.WaitFor(next_time_ns); 196 std::chrono::nanoseconds next_time_ns = std::chrono::nanoseconds(*next_time);
197 event.WaitFor(next_time_ns);
198 }
196 } else { 199 } else {
197 wait_set = true; 200 wait_set = true;
198 event.Wait(); 201 event.Wait();