From 033a42b5803728404375f09e32366b31fc963115 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Dec 2018 23:10:48 +0100 Subject: [PATCH] The syncd loop can just be a lambda. --- Kernel/Process.cpp | 2 +- Kernel/Process.h | 2 +- Kernel/Scheduler.cpp | 2 +- Kernel/init.cpp | 20 +++++++------------- Kernel/system.h | 2 -- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 0635a5aa13a..c41cce5f847 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -544,7 +544,7 @@ int Process::sys$get_arguments(int* argc, char*** argv) return 0; } -Process* Process::create_kernel_process(void (*e)(), String&& name) +Process* Process::create_kernel_process(String&& name, void (*e)()) { auto* process = new Process(move(name), (uid_t)0, (gid_t)0, (pid_t)0, Ring0); process->m_tss.eip = (dword)e; diff --git a/Kernel/Process.h b/Kernel/Process.h index 04e7e18e682..696fdbaf5f4 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -35,7 +35,7 @@ struct SignalActionData { class Process : public InlineLinkedListNode { friend class InlineLinkedListNode; public: - static Process* create_kernel_process(void (*entry)(), String&& name); + static Process* create_kernel_process(String&& name, void (*entry)()); static Process* create_user_process(const String& path, uid_t, gid_t, pid_t ppid, int& error, Vector&& arguments = Vector(), Vector&& environment = Vector(), TTY* = nullptr); ~Process(); diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index b3bb7060889..29e9dea6eaa 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -269,7 +269,7 @@ void Scheduler::initialize() memset(&s_redirection, 0, sizeof(s_redirection)); s_redirection.selector = gdt_alloc_entry(); initialize_redirection(); - s_colonel_process = Process::create_kernel_process(nullptr, "colonel"); + s_colonel_process = Process::create_kernel_process("colonel", nullptr); current = nullptr; load_task_register(s_redirection.selector); } diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 007e44349d6..356215d7c2f 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -16,7 +16,6 @@ #include #include #include "MemoryManager.h" - #include "ProcFileSystem.h" #include "RTC.h" #include "VirtualConsole.h" @@ -53,15 +52,6 @@ static void spawn_stress() } #endif -static void syncd() NORETURN; -static void syncd() -{ - for (;;) { - Syscall::sync(); - sleep(10 * TICKS_PER_SECOND); - } -} - static void init_stage2() NORETURN; static void init_stage2() { @@ -166,9 +156,13 @@ void init() procfs->initialize(); Process::initialize(); - Process::create_kernel_process(init_stage2, "init_stage2"); - - Process::create_kernel_process(syncd, "syncd"); + Process::create_kernel_process("init_stage2", init_stage2); + Process::create_kernel_process("syncd", [] { + for (;;) { + Syscall::sync(); + sleep(10 * TICKS_PER_SECOND); + } + }); Scheduler::pick_next(); diff --git a/Kernel/system.h b/Kernel/system.h index 689de3749cf..ae91545be91 100644 --- a/Kernel/system.h +++ b/Kernel/system.h @@ -1,8 +1,6 @@ #pragma once #include "types.h" -#include -#include struct system_t {