mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added GetProcessByID and GetThreadByID
This commit is contained in:
parent
a23d999183
commit
b104511241
@ -202,6 +202,23 @@ namespace Tasking
|
|||||||
PCB *Task::GetCurrentProcess() { return GetCurrentCPU()->CurrentProcess; }
|
PCB *Task::GetCurrentProcess() { return GetCurrentCPU()->CurrentProcess; }
|
||||||
TCB *Task::GetCurrentThread() { return GetCurrentCPU()->CurrentThread; }
|
TCB *Task::GetCurrentThread() { return GetCurrentCPU()->CurrentThread; }
|
||||||
|
|
||||||
|
PCB *Task::GetProcessByID(UPID ID)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < ListProcess.size(); i++)
|
||||||
|
if (ListProcess[i]->ID == ID)
|
||||||
|
return ListProcess[i];
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCB *Task::GetThreadByID(UTID ID)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < ListProcess.size(); i++)
|
||||||
|
for (size_t j = 0; j < ListProcess[i]->Threads.size(); j++)
|
||||||
|
if (ListProcess[i]->Threads[j]->ID == ID)
|
||||||
|
return ListProcess[i]->Threads[j];
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Task::WaitForProcess(PCB *pcb)
|
void Task::WaitForProcess(PCB *pcb)
|
||||||
{
|
{
|
||||||
if (!pcb)
|
if (!pcb)
|
||||||
|
@ -267,6 +267,7 @@ namespace Tasking
|
|||||||
void SignalShutdown();
|
void SignalShutdown();
|
||||||
void RevertProcessCreation(PCB *Process);
|
void RevertProcessCreation(PCB *Process);
|
||||||
void RevertThreadCreation(TCB *Thread);
|
void RevertThreadCreation(TCB *Thread);
|
||||||
|
|
||||||
long GetUsage(int Core)
|
long GetUsage(int Core)
|
||||||
{
|
{
|
||||||
if (IdleProcess)
|
if (IdleProcess)
|
||||||
@ -274,6 +275,7 @@ namespace Tasking
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KillThread(TCB *tcb, int Code)
|
void KillThread(TCB *tcb, int Code)
|
||||||
{
|
{
|
||||||
tcb->Status = TaskStatus::Terminated;
|
tcb->Status = TaskStatus::Terminated;
|
||||||
@ -298,6 +300,10 @@ namespace Tasking
|
|||||||
*/
|
*/
|
||||||
TCB *GetCurrentThread();
|
TCB *GetCurrentThread();
|
||||||
|
|
||||||
|
PCB *GetProcessByID(UPID ID);
|
||||||
|
|
||||||
|
TCB *GetThreadByID(UTID ID);
|
||||||
|
|
||||||
/** @brief Wait for process to terminate */
|
/** @brief Wait for process to terminate */
|
||||||
void WaitForProcess(PCB *pcb);
|
void WaitForProcess(PCB *pcb);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user