Fixed race conditions

This commit is contained in:
Alex 2023-02-19 01:54:38 +02:00
parent 07738ddb0a
commit 3f3db40026
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 3 additions and 11 deletions

View File

@ -163,16 +163,15 @@ void KernelMainThread()
KPrint("Starting Network Interface Manager..."); KPrint("Starting Network Interface Manager...");
NIManager->StartService(); NIManager->StartService();
KPrint("Setting up userspace");
#ifdef DEBUG #ifdef DEBUG
TreeFS(vfs->GetRootNode(), 0); TreeFS(vfs->GetRootNode(), 0);
#endif #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"; const char *USpace_msg = "Setting up userspace";
for (size_t i = 0; i < strlen(USpace_msg); i++) for (size_t i = 0; i < strlen(USpace_msg); i++)
Display->Print(USpace_msg[i], 0); Display->Print(USpace_msg[i], 0);
Display->SetBuffer(0); Display->SetBuffer(0);
Execute::SpawnData ret = {Execute::ExStatus::Unknown, nullptr, nullptr}; Execute::SpawnData ret = {Execute::ExStatus::Unknown, nullptr, nullptr};
@ -186,9 +185,6 @@ void KernelMainThread()
Display->Print('.', 0); Display->Print('.', 0);
Display->SetBuffer(0); Display->SetBuffer(0);
/* Prevent race conditions */
CPU::Interrupts(CPU::Disable);
ret = SpawnInit(); ret = SpawnInit();
Display->Print('.', 0); Display->Print('.', 0);
@ -207,11 +203,9 @@ void KernelMainThread()
Display->Print('\n', 0); Display->Print('\n', 0);
Display->SetBuffer(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); KPrint("Waiting for \e22AAFF%s\eCCCCCC to start...", Config.InitPath);
TaskManager->GetCurrentThread()->SetPriority(Tasking::Idle); TaskManager->GetCurrentThread()->SetPriority(Tasking::Idle);
TaskManager->WaitForThread(ret.Thread); TaskManager->WaitForThread(ret.Thread);
ExitCode = ret.Thread->GetExitCode(); ExitCode = ret.Thread->GetExitCode();
if (ExitCode != 0) if (ExitCode != 0)

View File

@ -154,10 +154,8 @@ namespace NetworkInterfaceManager
void NetworkInterface::StartService() void NetworkInterface::StartService()
{ {
CPU::Interrupts(CPU::Disable);
this->NetSvcThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)CallStartNetworkStackWrapper); this->NetSvcThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)CallStartNetworkStackWrapper);
this->NetSvcThread->Rename("Network Service"); this->NetSvcThread->Rename("Network Service");
CPU::Interrupts(CPU::Enable);
} }
void NetworkInterface::DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size) void NetworkInterface::DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size)