kernel: Add a way to lookup specific threads

This commit is contained in:
apio 2024-12-11 19:16:45 +01:00
parent 56a2b607b5
commit 2868fd8122
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 11 additions and 0 deletions

View File

@ -409,6 +409,16 @@ namespace Scheduler
return {}; return {};
} }
Option<Thread*> find_by_tid(pid_t tid)
{
for (auto* const thread : g_threads)
{
if (thread->tid == tid) return thread;
}
return {};
}
bool has_children(Process* process) bool has_children(Process* process)
{ {
bool result { false }; bool result { false };

View File

@ -38,6 +38,7 @@ namespace Scheduler
LinkedList<Process> check_for_dead_processes(); LinkedList<Process> check_for_dead_processes();
Option<Process*> find_by_pid(pid_t pid); Option<Process*> find_by_pid(pid_t pid);
Option<Thread*> find_by_tid(pid_t tid);
template <typename Callback> void for_each_child(Process* process, Callback callback) template <typename Callback> void for_each_child(Process* process, Callback callback)
{ {