kernel: Add names to threads
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4d3050eaab
commit
d48d0efb07
@ -219,7 +219,8 @@ namespace CPU
|
||||
|
||||
void platform_finish_init()
|
||||
{
|
||||
Scheduler::new_kernel_thread(io_thread).expect_value("Could not create the IO background thread!");
|
||||
Scheduler::new_kernel_thread(io_thread, "[x86_64-io]")
|
||||
.expect_value("Could not create the IO background thread!");
|
||||
|
||||
remap_pic();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ static Result<void> try_init_userspace()
|
||||
{
|
||||
auto init = TRY(VFS::resolve_path("/bin/init"));
|
||||
|
||||
TRY(Scheduler::new_userspace_thread(init));
|
||||
TRY(Scheduler::new_userspace_thread(init, "/bin/init"));
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -80,7 +80,7 @@ static void init_userspace()
|
||||
|
||||
static void create_reaper()
|
||||
{
|
||||
Scheduler::new_kernel_thread(reap_thread).release_value();
|
||||
Scheduler::new_kernel_thread(reap_thread, "[reap]").release_value();
|
||||
}
|
||||
|
||||
static void scan_pci()
|
||||
|
@ -81,6 +81,8 @@ Result<u64> sys_exec(Registers* regs, SyscallArgs args)
|
||||
|
||||
MMU::delete_userspace_page_directory(current->directory);
|
||||
|
||||
current->name = argv[0].chars();
|
||||
|
||||
image->apply(current);
|
||||
|
||||
MMU::switch_page_directory(current->directory);
|
||||
|
@ -24,6 +24,7 @@ namespace Scheduler
|
||||
g_idle.state = ThreadState::Idle;
|
||||
g_idle.is_kernel = true;
|
||||
g_idle.parent_id = 0;
|
||||
g_idle.name = "[idle]";
|
||||
|
||||
g_idle.ticks_left = 1;
|
||||
|
||||
@ -51,7 +52,7 @@ namespace Scheduler
|
||||
return &g_idle;
|
||||
}
|
||||
|
||||
Result<void> new_kernel_thread_impl(Thread* thread)
|
||||
Result<void> new_kernel_thread_impl(Thread* thread, const char* name)
|
||||
{
|
||||
// If anything fails, make sure to clean up.
|
||||
auto guard = make_scope_guard([&] { delete thread; });
|
||||
@ -67,6 +68,8 @@ namespace Scheduler
|
||||
|
||||
thread->parent_id = 0;
|
||||
|
||||
thread->name = name;
|
||||
|
||||
thread->is_kernel = true;
|
||||
|
||||
g_threads.append(thread);
|
||||
@ -76,39 +79,40 @@ namespace Scheduler
|
||||
return {};
|
||||
}
|
||||
|
||||
Result<void> new_kernel_thread(u64 address)
|
||||
Result<void> new_kernel_thread(u64 address, const char* name)
|
||||
{
|
||||
Thread* const thread = TRY(new_thread());
|
||||
thread->init_regs_kernel();
|
||||
thread->set_ip(address);
|
||||
|
||||
return new_kernel_thread_impl(thread);
|
||||
return new_kernel_thread_impl(thread, name);
|
||||
}
|
||||
|
||||
Result<void> new_kernel_thread(void (*func)(void))
|
||||
Result<void> new_kernel_thread(void (*func)(void), const char* name)
|
||||
{
|
||||
Thread* const thread = TRY(new_thread());
|
||||
thread->init_regs_kernel();
|
||||
thread->set_ip((u64)func);
|
||||
|
||||
return new_kernel_thread_impl(thread);
|
||||
return new_kernel_thread_impl(thread, name);
|
||||
}
|
||||
|
||||
Result<void> new_kernel_thread(void (*func)(void*), void* arg)
|
||||
Result<void> new_kernel_thread(void (*func)(void*), void* arg, const char* name)
|
||||
{
|
||||
Thread* const thread = TRY(new_thread());
|
||||
thread->init_regs_kernel();
|
||||
thread->set_ip((u64)func);
|
||||
thread->set_arguments((u64)arg, 0, 0, 0);
|
||||
|
||||
return new_kernel_thread_impl(thread);
|
||||
return new_kernel_thread_impl(thread, name);
|
||||
}
|
||||
|
||||
Result<void> new_userspace_thread(SharedPtr<VFS::Inode> inode)
|
||||
Result<void> new_userspace_thread(SharedPtr<VFS::Inode> inode, const char* name)
|
||||
{
|
||||
Thread* const thread = TRY(new_thread());
|
||||
|
||||
thread->is_kernel = false;
|
||||
thread->name = name;
|
||||
thread->parent_id = 0;
|
||||
|
||||
auto guard = make_scope_guard([&] { delete thread; });
|
||||
|
@ -9,11 +9,11 @@ namespace Scheduler
|
||||
Thread* current();
|
||||
Thread* idle();
|
||||
|
||||
Result<void> new_kernel_thread(u64 address);
|
||||
Result<void> new_kernel_thread(void (*func)(void));
|
||||
Result<void> new_kernel_thread(void (*func)(void*), void* arg);
|
||||
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<void> new_userspace_thread(SharedPtr<VFS::Inode> inode);
|
||||
Result<void> new_userspace_thread(SharedPtr<VFS::Inode> inode, const char* name);
|
||||
|
||||
void add_thread(Thread* thread);
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <luna/OwnedPtr.h>
|
||||
#include <luna/Result.h>
|
||||
#include <luna/Stack.h>
|
||||
#include <luna/StaticString.h>
|
||||
|
||||
#ifdef ARCH_X86_64
|
||||
#include "arch/x86_64/CPU.h"
|
||||
@ -68,6 +69,8 @@ struct Thread : public LinkedListNode<Thread>
|
||||
|
||||
u8 status { 0 };
|
||||
|
||||
StaticString<128> name;
|
||||
|
||||
PageDirectory* directory;
|
||||
|
||||
bool is_idle()
|
||||
|
Loading…
Reference in New Issue
Block a user