diff options
| author | 2019-03-15 23:28:29 -0400 | |
|---|---|---|
| committer | 2019-03-15 23:58:31 -0400 | |
| commit | c892cf01fad0c1fdeb6fc4644000c026176fe05a (patch) | |
| tree | 4a4b6aac7d872c204fb4b9d4279f041d04939d15 /src/core/hle/kernel/svc.cpp | |
| parent | Merge pull request #2211 from lioncash/arbiter (diff) | |
| download | yuzu-c892cf01fad0c1fdeb6fc4644000c026176fe05a.tar.gz yuzu-c892cf01fad0c1fdeb6fc4644000c026176fe05a.tar.xz yuzu-c892cf01fad0c1fdeb6fc4644000c026176fe05a.zip | |
kernel/thread: Migrate WaitCurrentThread_Sleep into the Thread interface
Rather than make a global accessor for this sort of thing. We can make
it a part of the thread interface itself. This allows getting rid of a
hidden global accessor in the kernel code.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 77d0e3d96..bf77ce137 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1300,32 +1300,32 @@ static void SleepThread(s64 nanoseconds) { | |||
| 1300 | YieldAndWaitForLoadBalancing = -2, | 1300 | YieldAndWaitForLoadBalancing = -2, |
| 1301 | }; | 1301 | }; |
| 1302 | 1302 | ||
| 1303 | auto& system = Core::System::GetInstance(); | ||
| 1304 | auto& scheduler = system.CurrentScheduler(); | ||
| 1305 | auto* const current_thread = scheduler.GetCurrentThread(); | ||
| 1306 | |||
| 1303 | if (nanoseconds <= 0) { | 1307 | if (nanoseconds <= 0) { |
| 1304 | auto& scheduler{Core::System::GetInstance().CurrentScheduler()}; | ||
| 1305 | switch (static_cast<SleepType>(nanoseconds)) { | 1308 | switch (static_cast<SleepType>(nanoseconds)) { |
| 1306 | case SleepType::YieldWithoutLoadBalancing: | 1309 | case SleepType::YieldWithoutLoadBalancing: |
| 1307 | scheduler.YieldWithoutLoadBalancing(GetCurrentThread()); | 1310 | scheduler.YieldWithoutLoadBalancing(current_thread); |
| 1308 | break; | 1311 | break; |
| 1309 | case SleepType::YieldWithLoadBalancing: | 1312 | case SleepType::YieldWithLoadBalancing: |
| 1310 | scheduler.YieldWithLoadBalancing(GetCurrentThread()); | 1313 | scheduler.YieldWithLoadBalancing(current_thread); |
| 1311 | break; | 1314 | break; |
| 1312 | case SleepType::YieldAndWaitForLoadBalancing: | 1315 | case SleepType::YieldAndWaitForLoadBalancing: |
| 1313 | scheduler.YieldAndWaitForLoadBalancing(GetCurrentThread()); | 1316 | scheduler.YieldAndWaitForLoadBalancing(current_thread); |
| 1314 | break; | 1317 | break; |
| 1315 | default: | 1318 | default: |
| 1316 | UNREACHABLE_MSG("Unimplemented sleep yield type '{:016X}'!", nanoseconds); | 1319 | UNREACHABLE_MSG("Unimplemented sleep yield type '{:016X}'!", nanoseconds); |
| 1317 | } | 1320 | } |
| 1318 | } else { | 1321 | } else { |
| 1319 | // Sleep current thread and check for next thread to schedule | 1322 | current_thread->Sleep(nanoseconds); |
| 1320 | WaitCurrentThread_Sleep(); | ||
| 1321 | |||
| 1322 | // Create an event to wake the thread up after the specified nanosecond delay has passed | ||
| 1323 | GetCurrentThread()->WakeAfterDelay(nanoseconds); | ||
| 1324 | } | 1323 | } |
| 1325 | 1324 | ||
| 1326 | // Reschedule all CPU cores | 1325 | // Reschedule all CPU cores |
| 1327 | for (std::size_t i = 0; i < Core::NUM_CPU_CORES; ++i) | 1326 | for (std::size_t i = 0; i < Core::NUM_CPU_CORES; ++i) { |
| 1328 | Core::System::GetInstance().CpuCore(i).PrepareReschedule(); | 1327 | system.CpuCore(i).PrepareReschedule(); |
| 1328 | } | ||
| 1329 | } | 1329 | } |
| 1330 | 1330 | ||
| 1331 | /// Wait process wide key atomic | 1331 | /// Wait process wide key atomic |