From 3f3db400269d7625a16b8375727d531bc9ec24e5 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 19 Feb 2023 01:54:38 +0200 Subject: [PATCH] Fixed race conditions --- KThread.cpp | 12 +++--------- Network/NetworkController.cpp | 2 -- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/KThread.cpp b/KThread.cpp index a0511ce..ef35f01 100644 --- a/KThread.cpp +++ b/KThread.cpp @@ -163,16 +163,15 @@ void KernelMainThread() KPrint("Starting Network Interface Manager..."); NIManager->StartService(); - KPrint("Setting up userspace"); - #ifdef DEBUG TreeFS(vfs->GetRootNode(), 0); #endif + Time::Clock tm = Time::ReadClock(); + printf("\eCCCCCC[\e00AEFF%02d:%02d:%02d\eCCCCCC] ", tm.Hour, tm.Minute, tm.Second); const char *USpace_msg = "Setting up userspace"; for (size_t i = 0; i < strlen(USpace_msg); i++) Display->Print(USpace_msg[i], 0); - Display->SetBuffer(0); Execute::SpawnData ret = {Execute::ExStatus::Unknown, nullptr, nullptr}; @@ -186,9 +185,6 @@ void KernelMainThread() Display->Print('.', 0); Display->SetBuffer(0); - /* Prevent race conditions */ - CPU::Interrupts(CPU::Disable); - ret = SpawnInit(); Display->Print('.', 0); @@ -207,11 +203,9 @@ void KernelMainThread() Display->Print('\n', 0); Display->SetBuffer(0); - /* Prevent the init process to execute syscalls without being trusted by the kernel */ - CPU::Interrupts(CPU::Enable); - KPrint("Waiting for \e22AAFF%s\eCCCCCC to start...", Config.InitPath); TaskManager->GetCurrentThread()->SetPriority(Tasking::Idle); + TaskManager->WaitForThread(ret.Thread); ExitCode = ret.Thread->GetExitCode(); if (ExitCode != 0) diff --git a/Network/NetworkController.cpp b/Network/NetworkController.cpp index f70fedf..2a87d34 100644 --- a/Network/NetworkController.cpp +++ b/Network/NetworkController.cpp @@ -154,10 +154,8 @@ namespace NetworkInterfaceManager void NetworkInterface::StartService() { - CPU::Interrupts(CPU::Disable); this->NetSvcThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)CallStartNetworkStackWrapper); this->NetSvcThread->Rename("Network Service"); - CPU::Interrupts(CPU::Enable); } void NetworkInterface::DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size)