Implement app management support (suspend, resume, close, etc) (#6322)

This commit is contained in:
Steveice10 2023-03-09 15:44:26 -08:00 committed by GitHub
parent d2caf2d386
commit c96f54f022
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 1043 additions and 110 deletions

View file

@ -133,6 +133,12 @@ public:
std::shared_ptr<Process> CreateProcess(std::shared_ptr<CodeSet> code_set);
/**
* Removes a process from the kernel process list
* @param process Process to remove
*/
void RemoveProcess(std::shared_ptr<Process> process);
/**
* Creates and returns a new thread. The new thread is immediately scheduled
* @param name The friendly name desired for the thread

View file

@ -79,6 +79,10 @@ std::shared_ptr<Process> KernelSystem::CreateProcess(std::shared_ptr<CodeSet> co
return process;
}
void KernelSystem::RemoveProcess(std::shared_ptr<Process> process) {
std::erase(process_list, process);
}
void Process::ParseKernelCaps(const u32* kernel_caps, std::size_t len) {
for (std::size_t i = 0; i < len; ++i) {
u32 descriptor = kernel_caps[i];
@ -208,9 +212,6 @@ void Process::Exit() {
if (plgldr) {
plgldr->OnProcessExit(*this, kernel);
}
// Clear the process's open handles.
handle_table.Clear();
}
VAddr Process::GetLinearHeapAreaAddress() const {
@ -474,6 +475,8 @@ Kernel::Process::Process(KernelSystem& kernel)
kernel.memory.RegisterPageTable(vm_manager.page_table);
}
Kernel::Process::~Process() {
LOG_INFO(Kernel, "Cleaning up process {}", process_id);
// Release all objects this process owns first so that their potential destructor can do clean
// up with this process before further destruction.
// TODO(wwylele): explicitly destroy or invalidate objects this process owns (threads, shared

View file

@ -565,6 +565,9 @@ void SVC::ExitProcess() {
// Kill the current thread
kernel.GetCurrentThreadManager().GetCurrentThread()->Stop();
// Remove kernel reference to process so it can be cleaned up.
kernel.RemoveProcess(current_process);
system.PrepareReschedule();
}