mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
tasking: Check for null pointer first
This commit is contained in:
parent
3709683af8
commit
4d192732cc
@ -111,7 +111,10 @@ void KernelMainThread()
|
|||||||
initProc = TaskManager->GetProcessByID(tid);
|
initProc = TaskManager->GetProcessByID(tid);
|
||||||
initThread = TaskManager->GetThreadByID(tid, initProc);
|
initThread = TaskManager->GetThreadByID(tid, initProc);
|
||||||
TaskManager->WaitForThread(initThread);
|
TaskManager->WaitForThread(initThread);
|
||||||
ExitCode = initThread->GetExitCode();
|
if (initThread)
|
||||||
|
ExitCode = initThread->GetExitCode();
|
||||||
|
else
|
||||||
|
ExitCode = 0xEBAD;
|
||||||
Exit:
|
Exit:
|
||||||
KPrint("\x1b[31mUserspace process exited with code %d (%#x)",
|
KPrint("\x1b[31mUserspace process exited with code %d (%#x)",
|
||||||
ExitCode, ExitCode < 0 ? -ExitCode : ExitCode);
|
ExitCode, ExitCode < 0 ? -ExitCode : ExitCode);
|
||||||
|
@ -157,6 +157,9 @@ namespace Tasking::Scheduler
|
|||||||
|
|
||||||
TCB *Custom::GetThreadByID(TID ID, PCB *Parent)
|
TCB *Custom::GetThreadByID(TID ID, PCB *Parent)
|
||||||
{
|
{
|
||||||
|
if (unlikely(Parent == nullptr))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
foreach (auto t in Parent->Threads)
|
foreach (auto t in Parent->Threads)
|
||||||
{
|
{
|
||||||
if (t->ID == ID)
|
if (t->ID == ID)
|
||||||
@ -544,6 +547,7 @@ namespace Tasking::Scheduler
|
|||||||
{
|
{
|
||||||
if (pcb->State.load() == TaskState::Terminated)
|
if (pcb->State.load() == TaskState::Terminated)
|
||||||
{
|
{
|
||||||
|
debug("Found terminated process %s(%d)", pcb->Name, pcb->ID);
|
||||||
delete pcb;
|
delete pcb;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,9 @@ namespace Tasking
|
|||||||
|
|
||||||
void Task::WaitForProcess(PCB *pcb)
|
void Task::WaitForProcess(PCB *pcb)
|
||||||
{
|
{
|
||||||
|
if (pcb == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pcb->State == TaskState::UnknownStatus)
|
if (pcb->State == TaskState::UnknownStatus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -119,6 +122,9 @@ namespace Tasking
|
|||||||
|
|
||||||
void Task::WaitForThread(TCB *tcb)
|
void Task::WaitForThread(TCB *tcb)
|
||||||
{
|
{
|
||||||
|
if (tcb == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (tcb->State == TaskState::UnknownStatus)
|
if (tcb->State == TaskState::UnknownStatus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -133,6 +139,9 @@ namespace Tasking
|
|||||||
|
|
||||||
void Task::WaitForProcessStatus(PCB *pcb, TaskState status)
|
void Task::WaitForProcessStatus(PCB *pcb, TaskState status)
|
||||||
{
|
{
|
||||||
|
if (pcb == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pcb->State == TaskState::UnknownStatus)
|
if (pcb->State == TaskState::UnknownStatus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -145,6 +154,9 @@ namespace Tasking
|
|||||||
|
|
||||||
void Task::WaitForThreadStatus(TCB *tcb, TaskState status)
|
void Task::WaitForThreadStatus(TCB *tcb, TaskState status)
|
||||||
{
|
{
|
||||||
|
if (tcb == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (tcb->State == TaskState::UnknownStatus)
|
if (tcb->State == TaskState::UnknownStatus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user