yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Kernel Scheduler: Make sure the global scheduler shutdowns correctly.

This commit is contained in:
Fernando Sahmkow 2019-10-12 08:21:51 -04:00 committed by FernandoS27
parent b3c1deba49
commit 25f8606a6d
7 changed files with 31 additions and 0 deletions

View File

@ -304,6 +304,13 @@ public:
return levels[priority == Depth ? 63 : priority].back(); return levels[priority == Depth ? 63 : priority].back();
} }
void clear() {
used_priorities = 0;
for (std::size_t i = 0; i < Depth; i++) {
levels[i].clear();
}
}
private: private:
using const_list_iterator = typename std::list<T>::const_iterator; using const_list_iterator = typename std::list<T>::const_iterator;

View File

@ -117,4 +117,8 @@ void Cpu::Reschedule() {
scheduler->TryDoContextSwitch(); scheduler->TryDoContextSwitch();
} }
void Cpu::Shutdown() {
scheduler->Shutdown();
}
} // namespace Core } // namespace Core

View File

@ -84,6 +84,8 @@ public:
return core_index; return core_index;
} }
void Shutdown();
static std::unique_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores); static std::unique_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores);
private: private:

View File

@ -58,6 +58,7 @@ void CpuCoreManager::Shutdown() {
thread_to_cpu.clear(); thread_to_cpu.clear();
for (auto& cpu_core : cores) { for (auto& cpu_core : cores) {
cpu_core->Shutdown();
cpu_core.reset(); cpu_core.reset();
} }

View File

@ -116,6 +116,8 @@ struct KernelCore::Impl {
thread_wakeup_event_type = nullptr; thread_wakeup_event_type = nullptr;
preemption_event = nullptr; preemption_event = nullptr;
global_scheduler.Shutdown();
named_ports.clear(); named_ports.clear();
} }

View File

@ -342,6 +342,14 @@ bool GlobalScheduler::AskForReselectionOrMarkRedundant(Thread* current_thread, T
} }
} }
void GlobalScheduler::Shutdown() {
for (std::size_t core = 0; core < NUM_CPU_CORES; core++) {
scheduled_queue[core].clear();
suggested_queue[core].clear();
}
thread_list.clear();
}
GlobalScheduler::~GlobalScheduler() = default; GlobalScheduler::~GlobalScheduler() = default;
Scheduler::Scheduler(Core::System& system, Core::ARM_Interface& cpu_core, u32 core_id) Scheduler::Scheduler(Core::System& system, Core::ARM_Interface& cpu_core, u32 core_id)

View File

@ -147,6 +147,8 @@ public:
return reselection_pending.load(); return reselection_pending.load();
} }
void Shutdown();
private: private:
bool AskForReselectionOrMarkRedundant(Thread* current_thread, Thread* winner); bool AskForReselectionOrMarkRedundant(Thread* current_thread, Thread* winner);
@ -189,6 +191,11 @@ public:
return context_switch_pending; return context_switch_pending;
} }
void Shutdown() {
current_thread = nullptr;
selected_thread = nullptr;
}
private: private:
friend class GlobalScheduler; friend class GlobalScheduler;
/** /**