mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-16 09:41:42 +00:00
Process cleanup should be done by a thread
This commit is contained in:
@@ -270,16 +270,6 @@ namespace Tasking
|
||||
return false;
|
||||
}
|
||||
|
||||
SafeFunction NIF void Task::SchedulerCleanupProcesses()
|
||||
{
|
||||
foreach (auto process in ListProcess)
|
||||
{
|
||||
if (InvalidPCB(process))
|
||||
continue;
|
||||
RemoveProcess(process);
|
||||
}
|
||||
}
|
||||
|
||||
SafeFunction NIF bool Task::SchedulerSearchProcessThread(void *CPUDataPointer)
|
||||
{
|
||||
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
||||
@@ -546,9 +536,6 @@ namespace Tasking
|
||||
}
|
||||
schedbg("Passed GetNextAvailableProcess");
|
||||
|
||||
this->SchedulerCleanupProcesses();
|
||||
schedbg("Passed SchedulerCleanupProcesses");
|
||||
|
||||
if (SchedulerSearchProcessThread(CurrentCPU))
|
||||
{
|
||||
#ifdef ON_SCREEN_SCHEDULER_TASK_MANAGER
|
||||
@@ -690,11 +677,6 @@ namespace Tasking
|
||||
fixme("unimplemented");
|
||||
}
|
||||
|
||||
SafeFunction void Task::SchedulerCleanupProcesses()
|
||||
{
|
||||
fixme("unimplemented");
|
||||
}
|
||||
|
||||
SafeFunction bool Task::SchedulerSearchProcessThread(void *CPUDataPointer)
|
||||
{
|
||||
fixme("unimplemented");
|
||||
@@ -722,11 +704,6 @@ namespace Tasking
|
||||
fixme("unimplemented");
|
||||
}
|
||||
|
||||
SafeFunction void Task::SchedulerCleanupProcesses()
|
||||
{
|
||||
fixme("unimplemented");
|
||||
}
|
||||
|
||||
SafeFunction bool Task::SchedulerSearchProcessThread(void *CPUDataPointer)
|
||||
{
|
||||
fixme("unimplemented");
|
||||
|
@@ -284,6 +284,21 @@ namespace Tasking
|
||||
// This should hang until all processes are terminated
|
||||
}
|
||||
|
||||
void Task::CleanupProcessesThread()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
this->Sleep(1000);
|
||||
foreach (auto process in ListProcess)
|
||||
{
|
||||
if (InvalidPCB(process))
|
||||
continue;
|
||||
|
||||
RemoveProcess(process);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Task::RevertProcessCreation(PCB *Process)
|
||||
{
|
||||
for (size_t i = 0; i < ListProcess.size(); i++)
|
||||
@@ -837,35 +852,24 @@ namespace Tasking
|
||||
Task::~Task()
|
||||
{
|
||||
debug("Destructor called");
|
||||
SmartLock(TaskingLock);
|
||||
trace("Stopping tasking");
|
||||
/*size_t ExpectedToBeTerminated = 0;
|
||||
foreach (PCB *Process in ListProcess)
|
||||
{
|
||||
foreach (TCB *Thread in Process->Threads)
|
||||
SmartLock(TaskingLock);
|
||||
foreach (PCB *Process in ListProcess)
|
||||
{
|
||||
if (Thread == GetCurrentCPU()->CurrentThread.Load())
|
||||
foreach (TCB *Thread in Process->Threads)
|
||||
{
|
||||
if (Thread == GetCurrentCPU()->CurrentThread.Load() ||
|
||||
Thread == CleanupThread)
|
||||
continue;
|
||||
this->KillThread(Thread, 0xFFFF);
|
||||
}
|
||||
|
||||
if (Process == GetCurrentCPU()->CurrentProcess.Load())
|
||||
continue;
|
||||
this->KillThread(Thread, 0xFFFF);
|
||||
ExpectedToBeTerminated++;
|
||||
this->KillProcess(Process, 0xFFFF);
|
||||
}
|
||||
|
||||
if (Process == GetCurrentCPU()->CurrentProcess.Load())
|
||||
continue;
|
||||
this->KillProcess(Process, 0xFFFF);
|
||||
ExpectedToBeTerminated++;
|
||||
}*/
|
||||
|
||||
foreach (PCB *Process in ListProcess)
|
||||
{
|
||||
foreach (TCB *Thread in Process->Threads)
|
||||
Thread->Status = TaskStatus::Terminated;
|
||||
|
||||
Process->Status = TaskStatus::Terminated;
|
||||
}
|
||||
|
||||
TaskingLock.Unlock();
|
||||
|
||||
while (ListProcess.size() > 0)
|
||||
{
|
||||
trace("Waiting for %d processes to terminate", ListProcess.size());
|
||||
@@ -877,7 +881,7 @@ namespace Tasking
|
||||
continue;
|
||||
NotTerminated++;
|
||||
}
|
||||
if (NotTerminated == 0 /*1*/)
|
||||
if (NotTerminated == 1)
|
||||
break;
|
||||
TaskingScheduler_OneShot(100);
|
||||
}
|
||||
|
Reference in New Issue
Block a user