1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

Kernel+LibPthread: Add support for usermode threads on x86_64

This commit is contained in:
Gunnar Beutner 2021-07-01 11:15:00 +02:00 committed by Andreas Kling
parent 93c741018e
commit 16b9a2d2e1
3 changed files with 21 additions and 8 deletions

View file

@ -70,6 +70,10 @@ KResultOr<FlatPtr> Process::sys$create_thread(void* (*entry)(void*), Userspace<c
regs.rip = (FlatPtr)entry;
regs.rflags = 0x0202;
regs.rsp = user_sp.value();
regs.rdi = params.rdi;
regs.rsi = params.rsi;
regs.rdx = params.rdx;
regs.rcx = params.rcx;
#endif
regs.cr3 = space().page_directory().cr3();
@ -81,11 +85,7 @@ KResultOr<FlatPtr> Process::sys$create_thread(void* (*entry)(void*), Userspace<c
ScopedSpinLock lock(g_scheduler_lock);
thread->set_priority(requested_thread_priority);
#if ARCH(I386)
thread->set_state(Thread::State::Runnable);
#else
dbgln("FIXME: Not starting thread {} (because it'd crash)", *thread);
#endif
return thread->tid().value();
}