forked from Bananymous/banan-os
Kernel: Fix Process::exit() and where it is called from
cksum doesn't seem to work anymore on big files. I have to look into this. It locks up after couple of seconds...
This commit is contained in:
parent
67e0c21e0f
commit
6f65453fd4
|
@ -1,5 +1,4 @@
|
|||
#include <BAN/StringView.h>
|
||||
#include <kernel/CriticalScope.h>
|
||||
#include <kernel/FS/VirtualFileSystem.h>
|
||||
#include <kernel/LockGuard.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
|
@ -61,6 +60,7 @@ namespace Kernel
|
|||
|
||||
Process::~Process()
|
||||
{
|
||||
if (!m_threads.empty())
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -85,14 +85,24 @@ namespace Kernel
|
|||
for (size_t i = 0; i < m_threads.size(); i++)
|
||||
if (m_threads[i] == &thread)
|
||||
m_threads.remove(i);
|
||||
if (m_threads.empty())
|
||||
exit();
|
||||
}
|
||||
|
||||
void Process::exit()
|
||||
{
|
||||
CriticalScope _;
|
||||
m_lock.lock();
|
||||
m_threads.clear();
|
||||
for (auto& open_fd : m_open_files)
|
||||
open_fd.inode = nullptr;
|
||||
|
||||
dprintln("process {} exit", pid());
|
||||
s_process_lock.lock();
|
||||
for (size_t i = 0; i < s_processes.size(); i++)
|
||||
if (s_processes[i] == this)
|
||||
s_processes.remove(i);
|
||||
s_process_lock.unlock();
|
||||
|
||||
Scheduler::get().set_current_process_done();
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,8 @@ namespace Kernel
|
|||
|
||||
void Scheduler::set_current_process_done()
|
||||
{
|
||||
VERIFY_CLI();
|
||||
VERIFY_STI();
|
||||
DISABLE_INTERRUPTS();
|
||||
|
||||
pid_t pid = m_current_thread->thread->process().pid();
|
||||
|
||||
|
@ -253,6 +254,7 @@ namespace Kernel
|
|||
remove_threads(m_sleeping_threads, it->thread->process().pid() == pid);
|
||||
remove_threads(m_active_threads, it != m_current_thread && it->thread->process().pid() == pid);
|
||||
|
||||
delete &m_current_thread->thread->process();
|
||||
delete m_current_thread->thread;
|
||||
remove_and_advance_current_thread();
|
||||
execute_current_thread();
|
||||
|
|
Loading…
Reference in New Issue