1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

Kernel: Finalizer should not go back to sleep if there's more to do

Before putting itself back on the wait queue, the finalizer task will
now check if there's more work to do, and if so, do it first. :^)

This patch also puts a bunch of process/thread debug logging behind
PROCESS_DEBUG and THREAD_DEBUG since it was unbearable to debug this
stuff with all the spam.
This commit is contained in:
Andreas Kling 2020-02-01 10:27:25 +01:00
parent 8d51352b96
commit 934b1d8a9b
5 changed files with 36 additions and 4 deletions

View file

@ -73,6 +73,7 @@
#include <LibC/signal_numbers.h>
#include <LibELF/ELFLoader.h>
//#define PROCESS_DEBUG
//#define DEBUG_POLL_SELECT
//#define DEBUG_IO
//#define TASK_DEBUG
@ -1295,7 +1296,9 @@ Process::Process(Thread*& first_thread, const String& name, uid_t uid, gid_t gid
, m_tty(tty)
, m_ppid(ppid)
{
#ifdef PROCESS_DEBUG
dbg() << "Created new process " << m_name << "(" << m_pid << ")";
#endif
m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr);
#ifdef MM_DEBUG
@ -2278,7 +2281,9 @@ int Process::reap(Process& process)
}
}
#ifdef PROCESS_DEBUG
dbg() << "Reaping process " << process;
#endif
ASSERT(process.is_dead());
g_processes->remove(&process);
}
@ -2289,7 +2294,10 @@ int Process::reap(Process& process)
pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
{
REQUIRE_PROMISE(stdio);
#ifdef PROCESS_DEBUG
dbg() << "sys$waitpid(" << waitee << ", " << wstatus << ", " << options << ")";
#endif
if (!options) {
// FIXME: This can't be right.. can it? Figure out how this should actually work.
@ -2928,7 +2936,9 @@ int Process::sys$chown(const Syscall::SC_chown_params* user_params)
void Process::finalize()
{
ASSERT(current == g_finalizer);
#ifdef PROCESS_DEBUG
dbg() << "Finalizing process " << *this;
#endif
m_fds.clear();
m_tty = nullptr;