Fix DisplayProcessScreen function to show ready threads, add note for hidden processes

This commit is contained in:
EnderIce2 2024-02-28 23:57:13 +02:00
parent 5fd8d3b3a5
commit 455c8a82de
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -508,7 +508,7 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
} }
} }
nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame) nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame, bool IgnoreReady = true)
{ {
const char *StatusColor[] = { const char *StatusColor[] = {
"FF0000", // Unknown "FF0000", // Unknown
@ -540,7 +540,7 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame)
if (!TaskManager) if (!TaskManager)
{ {
ExPrint("\eFF5555Scheduler is not initialized\n"); ExPrint("\eFF5555Tasking is not initialized\n");
return; return;
} }
@ -552,14 +552,29 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame)
ExPrint("\n\eFAFAFAProcess list (%ld):\n", Plist.size()); ExPrint("\n\eFAFAFAProcess list (%ld):\n", Plist.size());
bool pRdy = false; bool pRdy = false;
bool showNote = false;
/* FIXME: This is slow */
foreach (auto Process in Plist) foreach (auto Process in Plist)
{ {
if (Process->State == Tasking::Ready) bool ignore = true;
if (Process->State == Tasking::Ready && IgnoreReady)
{ {
pRdy = true; foreach (auto Thread in Process->Threads)
debug("Ignoring ready process %s(%d)", {
Process->Name, Process->ID); if (Thread->State == Tasking::Ready)
continue; continue;
ignore = false;
break;
}
if (ignore)
{
pRdy = true;
debug("Ignoring ready process %s(%d)",
Process->Name, Process->ID);
showNote = true;
continue;
}
} }
ExPrint("\eAAAAAA-> \eFAFAFA%.*s%s\e8A8A8A(%ld) \e%s%s\n", ExPrint("\eAAAAAA-> \eFAFAFA%.*s%s\e8A8A8A(%ld) \e%s%s\n",
@ -571,11 +586,12 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame)
bool tRdy = false; bool tRdy = false;
foreach (auto Thread in Process->Threads) foreach (auto Thread in Process->Threads)
{ {
if (Thread->State == Tasking::Ready) if (Thread->State == Tasking::Ready && IgnoreReady)
{ {
tRdy = true; tRdy = true;
debug("Ignoring ready thread %s(%d)", debug("Ignoring ready thread %s(%d)",
Thread->Name, Thread->ID); Thread->Name, Thread->ID);
showNote = true;
continue; continue;
} }
@ -591,7 +607,8 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame)
if (pRdy) if (pRdy)
ExPrint("\eAAAAAA-> \e8A8A8A...\n"); ExPrint("\eAAAAAA-> \e8A8A8A...\n");
ExPrint("\e5A5A5ANote: Some processes may not be displayed.\n"); if (showNote)
ExPrint("\e5A5A5ANote: Some processes may not be displayed.\n");
} }
CPU::ExceptionFrame *ExFrame; CPU::ExceptionFrame *ExFrame;
@ -908,6 +925,10 @@ nsa void UserInput(char *Input)
CPU::PageTable((void *)ExFrame->cr3); CPU::PageTable((void *)ExFrame->cr3);
ExPrint("Here be dragons\n"); ExPrint("Here be dragons\n");
} }
else if (strcmp(Input, "ps") == 0)
{
DisplayProcessScreen(ExFrame, false);
}
#endif // DEBUG #endif // DEBUG
else if (strlen(Input) > 0) else if (strlen(Input) > 0)
ExPrint("Unknown command: %s", Input); ExPrint("Unknown command: %s", Input);