mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Improved shutting down procedure
This commit is contained in:
parent
ffdbc6e598
commit
3f166b97c7
@ -47,7 +47,7 @@ void KernelMainThread()
|
||||
KPrint("Initializing Network Interface Manager...");
|
||||
NIManager = new NetworkInterfaceManager::NetworkInterface;
|
||||
KPrint("Starting Network Interface Manager...");
|
||||
// NIManager->StartService();
|
||||
NIManager->StartService();
|
||||
|
||||
KPrint("Setting up userspace...");
|
||||
|
||||
@ -91,10 +91,7 @@ Exit:
|
||||
|
||||
void KernelShutdownThread(bool Reboot)
|
||||
{
|
||||
delete NIManager;
|
||||
|
||||
if (DriverManager)
|
||||
DriverManager->UnloadAllDrivers();
|
||||
BeforeShutdown();
|
||||
|
||||
trace("Shutting Down/Rebooting...");
|
||||
if (Reboot)
|
||||
|
20
Kernel.cpp
20
Kernel.cpp
@ -248,6 +248,26 @@ EXTERNC __no_stack_protector __no_instrument_function void Entry(BootInfo *Info)
|
||||
|
||||
EXTERNC __no_stack_protector __no_instrument_function void BeforeShutdown()
|
||||
{
|
||||
/* TODO: Announce shutdown */
|
||||
|
||||
trace("\n\n\n#################### SYSTEM SHUTTING DOWN ####################\n\n");
|
||||
delete NIManager;
|
||||
|
||||
delete DiskManager;
|
||||
if (DriverManager)
|
||||
DriverManager->UnloadAllDrivers();
|
||||
delete DriverManager;
|
||||
|
||||
TaskManager->SignalShutdown();
|
||||
delete TaskManager;
|
||||
|
||||
delete RecoveryScreen;
|
||||
delete vfs;
|
||||
delete TimeManager;
|
||||
delete KernelSymbolTable;
|
||||
delete Display;
|
||||
// PowerManager should not be called
|
||||
|
||||
// https://wiki.osdev.org/Calling_Global_Constructors
|
||||
debug("Calling destructors...");
|
||||
for (CallPtr *func = __fini_array_start; func != __fini_array_end; func++)
|
||||
|
@ -743,6 +743,13 @@ namespace Tasking
|
||||
OneShot(1);
|
||||
}
|
||||
|
||||
void Task::SignalShutdown()
|
||||
{
|
||||
fixme("SignalShutdown()");
|
||||
// TODO: Implement this
|
||||
// This should hang until all processes are terminated
|
||||
}
|
||||
|
||||
TCB *Task::CreateThread(PCB *Parent,
|
||||
IP EntryPoint,
|
||||
const char **argv,
|
||||
@ -1210,5 +1217,34 @@ namespace Tasking
|
||||
{
|
||||
SmartCriticalSection(TaskingLock);
|
||||
trace("Stopping tasking");
|
||||
foreach (auto Process in ListProcess)
|
||||
{
|
||||
for (auto &Thread : Process->Threads)
|
||||
{
|
||||
Thread->Status = TaskStatus::Terminated;
|
||||
}
|
||||
Process->Status = TaskStatus::Terminated;
|
||||
}
|
||||
|
||||
TaskingLock.Unlock();
|
||||
SchedulerLock.Unlock();
|
||||
|
||||
while (ListProcess.size() > 0)
|
||||
{
|
||||
trace("Waiting for %d processes to terminate", ListProcess.size());
|
||||
int NotTerminated = 0;
|
||||
foreach (auto Process in ListProcess)
|
||||
{
|
||||
debug("Process %s(%d) is still running (or waiting to be removed status %#lx)", Process->Name, Process->ID, Process->Status);
|
||||
if (Process->Status == TaskStatus::Terminated)
|
||||
continue;
|
||||
NotTerminated++;
|
||||
}
|
||||
if (NotTerminated == 0)
|
||||
break;
|
||||
OneShot(100);
|
||||
}
|
||||
|
||||
trace("Tasking stopped");
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ namespace Tasking
|
||||
Vector<PCB *> GetProcessList() { return ListProcess; }
|
||||
void Panic() { StopScheduler = true; }
|
||||
void Schedule();
|
||||
void SignalShutdown();
|
||||
long GetUsage(int Core)
|
||||
{
|
||||
if (IdleProcess)
|
||||
|
Loading…
x
Reference in New Issue
Block a user