diff options
| author | 2020-12-20 20:57:54 -0800 | |
|---|---|---|
| committer | 2020-12-20 20:57:54 -0800 | |
| commit | 1279c7ce7afd3d1bf2b4e33aa922158acf2cd060 (patch) | |
| tree | 6db8088caed2bd957187e4730f51424325038fa5 /src/core/hle/kernel/synchronization.cpp | |
| parent | Merge pull request #5201 from ameerj/bufferq-refactor (diff) | |
| parent | hle: kernel: Process: Various style fixes based on code review feedback. (diff) | |
| download | yuzu-1279c7ce7afd3d1bf2b4e33aa922158acf2cd060.tar.gz yuzu-1279c7ce7afd3d1bf2b4e33aa922158acf2cd060.tar.xz yuzu-1279c7ce7afd3d1bf2b4e33aa922158acf2cd060.zip | |
Merge pull request #5131 from bunnei/scheduler-rewrite
Rewrite Kernel scheduler based on Atmosphere
Diffstat (limited to 'src/core/hle/kernel/synchronization.cpp')
| -rw-r--r-- | src/core/hle/kernel/synchronization.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core/hle/kernel/synchronization.cpp b/src/core/hle/kernel/synchronization.cpp index 8b875d853..d3f520ea2 100644 --- a/src/core/hle/kernel/synchronization.cpp +++ b/src/core/hle/kernel/synchronization.cpp | |||
| @@ -5,8 +5,9 @@ | |||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/kernel/errors.h" | 6 | #include "core/hle/kernel/errors.h" |
| 7 | #include "core/hle/kernel/handle_table.h" | 7 | #include "core/hle/kernel/handle_table.h" |
| 8 | #include "core/hle/kernel/k_scheduler.h" | ||
| 9 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | ||
| 8 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 9 | #include "core/hle/kernel/scheduler.h" | ||
| 10 | #include "core/hle/kernel/synchronization.h" | 11 | #include "core/hle/kernel/synchronization.h" |
| 11 | #include "core/hle/kernel/synchronization_object.h" | 12 | #include "core/hle/kernel/synchronization_object.h" |
| 12 | #include "core/hle/kernel/thread.h" | 13 | #include "core/hle/kernel/thread.h" |
| @@ -18,7 +19,7 @@ Synchronization::Synchronization(Core::System& system) : system{system} {} | |||
| 18 | 19 | ||
| 19 | void Synchronization::SignalObject(SynchronizationObject& obj) const { | 20 | void Synchronization::SignalObject(SynchronizationObject& obj) const { |
| 20 | auto& kernel = system.Kernel(); | 21 | auto& kernel = system.Kernel(); |
| 21 | SchedulerLock lock(kernel); | 22 | KScopedSchedulerLock lock(kernel); |
| 22 | if (obj.IsSignaled()) { | 23 | if (obj.IsSignaled()) { |
| 23 | for (auto thread : obj.GetWaitingThreads()) { | 24 | for (auto thread : obj.GetWaitingThreads()) { |
| 24 | if (thread->GetSchedulingStatus() == ThreadSchedStatus::Paused) { | 25 | if (thread->GetSchedulingStatus() == ThreadSchedStatus::Paused) { |
| @@ -37,10 +38,10 @@ void Synchronization::SignalObject(SynchronizationObject& obj) const { | |||
| 37 | std::pair<ResultCode, Handle> Synchronization::WaitFor( | 38 | std::pair<ResultCode, Handle> Synchronization::WaitFor( |
| 38 | std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds) { | 39 | std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds) { |
| 39 | auto& kernel = system.Kernel(); | 40 | auto& kernel = system.Kernel(); |
| 40 | auto* const thread = system.CurrentScheduler().GetCurrentThread(); | 41 | auto* const thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 41 | Handle event_handle = InvalidHandle; | 42 | Handle event_handle = InvalidHandle; |
| 42 | { | 43 | { |
| 43 | SchedulerLockAndSleep lock(kernel, event_handle, thread, nano_seconds); | 44 | KScopedSchedulerLockAndSleep lock(kernel, event_handle, thread, nano_seconds); |
| 44 | const auto itr = | 45 | const auto itr = |
| 45 | std::find_if(sync_objects.begin(), sync_objects.end(), | 46 | std::find_if(sync_objects.begin(), sync_objects.end(), |
| 46 | [thread](const std::shared_ptr<SynchronizationObject>& object) { | 47 | [thread](const std::shared_ptr<SynchronizationObject>& object) { |
| @@ -89,7 +90,7 @@ std::pair<ResultCode, Handle> Synchronization::WaitFor( | |||
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | { | 92 | { |
| 92 | SchedulerLock lock(kernel); | 93 | KScopedSchedulerLock lock(kernel); |
| 93 | ResultCode signaling_result = thread->GetSignalingResult(); | 94 | ResultCode signaling_result = thread->GetSignalingResult(); |
| 94 | SynchronizationObject* signaling_object = thread->GetSignalingObject(); | 95 | SynchronizationObject* signaling_object = thread->GetSignalingObject(); |
| 95 | thread->SetSynchronizationObjects(nullptr); | 96 | thread->SetSynchronizationObjects(nullptr); |