diff options
| author | lizzie <lizzie@eden-emu.dev> | 2025-12-31 17:31:12 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-12-31 17:31:12 +0100 |
| commit | 8f430d25a66d5db63b8174925c7c45d7073760d0 (patch) | |
| tree | 157cb48cb9f7b082fe5bed959399d3ef6598d26f /src/core/hle/kernel/k_scheduler.cpp | |
| parent | e6ff7116133c340b3816a3e6c7c8c02337bc45b0 (diff) | |
[core/hle] use boost::container::small_vector<> instead of std::set<> of dummy threads (#3025)
2048 bytes of static storage (128 threads) is more than enough for most applications
Highly hit or miss (most likely miss) - check with TOTK beforehand, should bring perf stuff to Android; in theory
Signed-off-by: lizzie lizzie@eden-emu.dev
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3025
Reviewed-by: DraVee <dravee@eden-emu.dev>
Reviewed-by: Maufeat <sahyno1996@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/core/hle/kernel/k_scheduler.cpp')
| -rw-r--r-- | src/core/hle/kernel/k_scheduler.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index 676e19190a..28d39320e4 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp @@ -527,35 +527,27 @@ void KScheduler::ClearPreviousThread(KernelCore& kernel, KThread* thread) { void KScheduler::OnThreadStateChanged(KernelCore& kernel, KThread* thread, ThreadState old_state) { ASSERT(IsSchedulerLockedByCurrentThread(kernel)); - // Check if the state has changed, because if it hasn't there's nothing to do. - const ThreadState cur_state = thread->GetRawState(); - if (cur_state == old_state) { - return; - } - - // Update the priority queues. - if (old_state == ThreadState::Runnable) { - // If we were previously runnable, then we're not runnable now, and we should remove. - GetPriorityQueue(kernel).Remove(thread); - IncrementScheduledCount(thread); - SetSchedulerUpdateNeeded(kernel); - - if (thread->IsDummyThread()) { + if (const ThreadState cur_state = thread->GetRawState(); cur_state != old_state) { + // Update the priority queues. + if (old_state == ThreadState::Runnable) { + // If we were previously runnable, then we're not runnable now, and we should remove. + GetPriorityQueue(kernel).Remove(thread); + IncrementScheduledCount(thread); + SetSchedulerUpdateNeeded(kernel); // HACK: if this is a dummy thread, it should no longer wake up when the // scheduler lock is released. - kernel.GlobalSchedulerContext().UnregisterDummyThreadForWakeup(thread); - } - } else if (cur_state == ThreadState::Runnable) { - // If we're now runnable, then we weren't previously, and we should add. - GetPriorityQueue(kernel).PushBack(thread); - IncrementScheduledCount(thread); - SetSchedulerUpdateNeeded(kernel); - - if (thread->IsDummyThread()) { + if (thread->IsDummyThread()) + kernel.GlobalSchedulerContext().UnregisterDummyThreadForWakeup(thread); + } else if (cur_state == ThreadState::Runnable) { + // If we're now runnable, then we weren't previously, and we should add. + GetPriorityQueue(kernel).PushBack(thread); + IncrementScheduledCount(thread); + SetSchedulerUpdateNeeded(kernel); // HACK: if this is a dummy thread, it should wake up when the scheduler // lock is released. - kernel.GlobalSchedulerContext().RegisterDummyThreadForWakeup(thread); + if (thread->IsDummyThread()) + kernel.GlobalSchedulerContext().RegisterDummyThreadForWakeup(thread); } } } |
