From 884ce30c07ddff4550d2d1512e3652e33534700a Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 5 Nov 2011 18:49:30 +0100 Subject: [PATCH] The scheduler now keeps track of the initial process. --- sortix/kernel.cpp | 1 + sortix/scheduler.cpp | 10 ++++++++-- sortix/scheduler.h | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) 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);