summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-04-02 15:22:53 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-15 17:55:12 +0200
commitfcc6b34fff3c9322a35e6457a699e70585a7e014 (patch)
tree7fbd96994170ff2707f65e42dc6a4832c6531d07 /src/core/hle/kernel
parentComment and reorganize the scheduler (diff)
downloadyuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar
yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.gz
yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.bz2
yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.lz
yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.xz
yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.tar.zst
yuzu-fcc6b34fff3c9322a35e6457a699e70585a7e014.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp5
-rw-r--r--src/core/hle/kernel/svc.cpp49
-rw-r--r--src/core/hle/kernel/wait_object.cpp3
3 files changed, 20 insertions, 37 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 77f7bb451..c66cd16ef 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -37,8 +37,7 @@ void WakeThreads(const std::vector<SharedPtr<Thread>>& waiting_threads, s32 num_
waiting_threads[i]->SetWaitSynchronizationResult(RESULT_SUCCESS);
waiting_threads[i]->SetArbiterWaitAddress(0);
waiting_threads[i]->ResumeFromWait();
- if (waiting_threads[i]->GetProcessorID() >= 0)
- system.CpuCore(waiting_threads[i]->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(waiting_threads[i]->GetProcessorID());
}
}
} // Anonymous namespace
@@ -173,7 +172,7 @@ ResultCode AddressArbiter::WaitForAddressImpl(VAddr address, s64 timeout) {
current_thread->WakeAfterDelay(timeout);
- system.CpuCore(current_thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(current_thread->GetProcessorID());
return RESULT_TIMEOUT;
}
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index ee1e9f006..560ac3945 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -516,7 +516,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
thread->WakeAfterDelay(nano_seconds);
thread->SetWakeupCallback(DefaultThreadWakeupCallback);
- system.CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
return RESULT_TIMEOUT;
}
@@ -534,8 +534,7 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand
}
thread->CancelWait();
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
return RESULT_SUCCESS;
}
@@ -1069,8 +1068,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act
thread->SetActivity(static_cast<ThreadActivity>(activity));
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
return RESULT_SUCCESS;
}
@@ -1152,8 +1150,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri
thread->SetPriority(priority);
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
return RESULT_SUCCESS;
}
@@ -1509,8 +1506,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
thread->SetName(
fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle));
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
return RESULT_SUCCESS;
}
@@ -1532,10 +1528,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) {
thread->ResumeFromWait();
if (thread->GetStatus() == ThreadStatus::Ready) {
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
- else
- Core::System::GetInstance().GlobalScheduler().SetReselectionPending();
+ system.PrepareReschedule(thread->GetProcessorID());
}
return RESULT_SUCCESS;
@@ -1582,10 +1575,7 @@ static void SleepThread(Core::System& system, s64 nanoseconds) {
current_thread->Sleep(nanoseconds);
}
- // Reschedule all CPU cores
- for (std::size_t i = 0; i < Core::NUM_CPU_CORES; ++i) {
- system.CpuCore(i).PrepareReschedule();
- }
+ system.PrepareReschedule(current_thread->GetProcessorID());
}
/// Wait process wide key atomic
@@ -1632,7 +1622,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add
// Note: Deliberately don't attempt to inherit the lock owner's priority.
- system.CpuCore(current_thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(current_thread->GetProcessorID());
return RESULT_SUCCESS;
}
@@ -1644,7 +1634,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
// Retrieve a list of all threads that are waiting for this condition variable.
std::vector<SharedPtr<Thread>> waiting_threads;
- const auto& scheduler = Core::System::GetInstance().GlobalScheduler();
+ const auto& scheduler = system.GlobalScheduler();
const auto& thread_list = scheduler.GetThreadList();
for (const auto& thread : thread_list) {
@@ -1706,8 +1696,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
thread->SetLockOwner(nullptr);
thread->SetMutexWaitAddress(0);
thread->SetWaitHandle(0);
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
} else {
// Atomically signal that the mutex now has a waiting thread.
do {
@@ -1731,8 +1720,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
thread->SetStatus(ThreadStatus::WaitMutex);
owner->AddMutexWaiter(thread);
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
}
}
@@ -1758,13 +1746,10 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type,
}
const auto arbitration_type = static_cast<AddressArbiter::ArbitrationType>(type);
- auto& address_arbiter =
- system.Kernel().CurrentProcess()->GetAddressArbiter();
+ auto& address_arbiter = system.Kernel().CurrentProcess()->GetAddressArbiter();
ResultCode result = address_arbiter.WaitForAddress(address, arbitration_type, value, timeout);
if (result == RESULT_SUCCESS)
- Core::System::GetInstance()
- .CpuCore(GetCurrentThread()->GetProcessorID())
- .PrepareReschedule();
+ system.PrepareReschedule();
return result;
}
@@ -2051,10 +2036,10 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle,
return ERR_INVALID_HANDLE;
}
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
thread->ChangeCore(core, affinity_mask);
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ system.PrepareReschedule(thread->GetProcessorID());
+
return RESULT_SUCCESS;
}
@@ -2165,7 +2150,7 @@ static ResultCode SignalEvent(Core::System& system, Handle handle) {
}
writable_event->Signal();
- Core::System::GetInstance().PrepareReschedule();
+ system.PrepareReschedule();
return RESULT_SUCCESS;
}
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp
index e035a67e9..a65ec7dbc 100644
--- a/src/core/hle/kernel/wait_object.cpp
+++ b/src/core/hle/kernel/wait_object.cpp
@@ -97,8 +97,7 @@ void WaitObject::WakeupWaitingThread(SharedPtr<Thread> thread) {
}
if (resume) {
thread->ResumeFromWait();
- if (thread->GetProcessorID() >= 0)
- Core::System::GetInstance().CpuCore(thread->GetProcessorID()).PrepareReschedule();
+ Core::System::GetInstance().PrepareReschedule(thread->GetProcessorID());
}
}