diff --git a/sortix/kernel.cpp b/sortix/kernel.cpp index bb9967aa..e81412a0 100644 --- a/sortix/kernel.cpp +++ b/sortix/kernel.cpp @@ -283,6 +283,7 @@ namespace Sortix if ( !initstart ) { Panic("could not construct ELF image for init process"); } Thread* initthread = CreateThread(initstart); if ( !initthread ) { Panic("could not create thread for the init process"); } + Scheduler::SetInitProcess(init); // Lastly set up the timer driver and we are ready to run the OS. Time::Init(); diff --git a/sortix/scheduler.cpp b/sortix/scheduler.cpp index f7cb66e7..f991f2fe 100644 --- a/sortix/scheduler.cpp +++ b/sortix/scheduler.cpp @@ -55,6 +55,7 @@ namespace Sortix Thread* idlethread; Thread* firstrunnablethread; Thread* firstsleepingthread; + Process* initprocess; bool hacksigintpending = false; void Init() @@ -89,9 +90,14 @@ namespace Sortix dummythread->process = process; } - void SetInitialProcess(Process* init) + void SetInitProcess(Process* init) { - dummythread->process = init; + initprocess = init; + } + + Process* GetInitProcess() + { + return initprocess; } void MainLoop() diff --git a/sortix/scheduler.h b/sortix/scheduler.h index e65dbe52..53061f58 100644 --- a/sortix/scheduler.h +++ b/sortix/scheduler.h @@ -35,7 +35,9 @@ namespace Sortix void MainLoop() SORTIX_NORETURN; void Switch(CPU::InterruptRegisters* regs); void SetIdleThread(Thread* thread); - void SetDummyThreadOwner(Process* init); + void SetDummyThreadOwner(Process* process); + void SetInitProcess(Process* init); + Process* GetInitProcess(); void SetThreadState(Thread* thread, Thread::State state); Thread::State GetThreadState(Thread* thread);