52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#pragma once
|
|
#include "fs/VFS.h"
|
|
#include "thread/Thread.h"
|
|
|
|
namespace Scheduler
|
|
{
|
|
void init();
|
|
|
|
Thread* current();
|
|
Thread* idle();
|
|
|
|
Result<void> new_kernel_thread(u64 address, const char* name);
|
|
Result<void> new_kernel_thread(void (*func)(void), const char* name);
|
|
Result<void> new_kernel_thread(void (*func)(void*), void* arg, const char* name);
|
|
|
|
Result<Thread*> new_userspace_thread(SharedPtr<VFS::Inode> inode, const char* name);
|
|
|
|
void add_thread(Thread* thread);
|
|
|
|
Thread* pick_task();
|
|
|
|
void reap_thread(Thread* thread);
|
|
|
|
void switch_task(Registers* regs);
|
|
|
|
void invoke(Registers* regs);
|
|
|
|
LinkedList<Thread> check_for_dying_threads();
|
|
|
|
Option<Thread*> find_by_pid(pid_t pid);
|
|
|
|
template <typename Callback> void for_each_child(pid_t pid, Callback callback)
|
|
{
|
|
for (auto* const thread : g_threads)
|
|
{
|
|
if (thread->parent_id == (u64)pid)
|
|
{
|
|
bool should_continue = callback(thread);
|
|
if (!should_continue) return;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool has_children(pid_t pid);
|
|
|
|
Option<Thread*> find_exited_child(pid_t pid);
|
|
}
|
|
|
|
extern "C" void kernel_yield();
|
|
void kernel_sleep(u64 ms);
|
|
[[noreturn]] void kernel_exit();
|