|
|
|
@ -91,12 +91,6 @@ struct KernelCore::Impl {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Shutdown() {
|
|
|
|
|
// Shutdown all processes.
|
|
|
|
|
if (current_process) {
|
|
|
|
|
current_process->Finalize();
|
|
|
|
|
current_process->Close();
|
|
|
|
|
current_process = nullptr;
|
|
|
|
|
}
|
|
|
|
|
process_list.clear();
|
|
|
|
|
|
|
|
|
|
// Close all open server ports.
|
|
|
|
@ -170,6 +164,24 @@ struct KernelCore::Impl {
|
|
|
|
|
// Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others
|
|
|
|
|
next_host_thread_id = Core::Hardware::NUM_CPU_CORES;
|
|
|
|
|
|
|
|
|
|
// Close kernel objects that were not freed on shutdown
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard lk(registered_in_use_objects_lock);
|
|
|
|
|
if (registered_in_use_objects.size()) {
|
|
|
|
|
for (auto& object : registered_in_use_objects) {
|
|
|
|
|
object->Close();
|
|
|
|
|
}
|
|
|
|
|
registered_in_use_objects.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shutdown all processes.
|
|
|
|
|
if (current_process) {
|
|
|
|
|
current_process->Finalize();
|
|
|
|
|
current_process->Close();
|
|
|
|
|
current_process = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Track kernel objects that were not freed on shutdown
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard lk(registered_objects_lock);
|
|
|
|
@ -714,9 +726,11 @@ struct KernelCore::Impl {
|
|
|
|
|
std::unordered_set<KServerPort*> server_ports;
|
|
|
|
|
std::unordered_set<KServerSession*> server_sessions;
|
|
|
|
|
std::unordered_set<KAutoObject*> registered_objects;
|
|
|
|
|
std::unordered_set<KAutoObject*> registered_in_use_objects;
|
|
|
|
|
std::mutex server_ports_lock;
|
|
|
|
|
std::mutex server_sessions_lock;
|
|
|
|
|
std::mutex registered_objects_lock;
|
|
|
|
|
std::mutex registered_in_use_objects_lock;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor;
|
|
|
|
|
std::vector<Kernel::PhysicalCore> cores;
|
|
|
|
@ -928,6 +942,16 @@ void KernelCore::UnregisterKernelObject(KAutoObject* object) {
|
|
|
|
|
impl->registered_objects.erase(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KernelCore::RegisterInUseObject(KAutoObject* object) {
|
|
|
|
|
std::lock_guard lk(impl->registered_in_use_objects_lock);
|
|
|
|
|
impl->registered_in_use_objects.insert(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KernelCore::UnregisterInUseObject(KAutoObject* object) {
|
|
|
|
|
std::lock_guard lk(impl->registered_in_use_objects_lock);
|
|
|
|
|
impl->registered_in_use_objects.erase(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KernelCore::IsValidNamedPort(NamedPortTable::const_iterator port) const {
|
|
|
|
|
return port != impl->named_ports.cend();
|
|
|
|
|
}
|
|
|
|
|