From ab8ca388bbc62c2931aa9e47b31bc808376d280b Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Mon, 25 Mar 2024 15:12:21 +0200 Subject: [PATCH] Add GetThread() function to PCB class --- include/task.hpp | 1 + tasking/process.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/task.hpp b/include/task.hpp index 89870f6e..806a91e7 100644 --- a/include/task.hpp +++ b/include/task.hpp @@ -473,6 +473,7 @@ namespace Tasking void SetWorkingDirectory(Node *node); void SetExe(const char *path); size_t GetSize(); + TCB *GetThread(TID ID); PCB(class Task *ctx, PCB *Parent, diff --git a/tasking/process.cpp b/tasking/process.cpp index 734252e2..692aff18 100644 --- a/tasking/process.cpp +++ b/tasking/process.cpp @@ -48,6 +48,14 @@ using namespace vfs; namespace Tasking { + TCB *PCB::GetThread(TID ID) + { + auto it = std::find_if(this->Threads.begin(), this->Threads.end(), + [ID](TCB *t) + { return t->ID == ID; }); + return it != this->Threads.end() ? *it : nullptr; + } + int PCB::SendSignal(int sig) { return this->Signals->SendSignal(sig);