sched: implement passing arguments to user-mode threads

This commit is contained in:
2026-02-19 19:04:00 +00:00
parent b188573eea
commit 291a5f677e
3 changed files with 82 additions and 6 deletions

View File

@@ -54,7 +54,9 @@ kern_status_t thread_init_kernel(struct thread *thr, virt_addr_t ip)
kern_status_t thread_init_user(
struct thread *thr,
virt_addr_t ip,
virt_addr_t sp)
virt_addr_t sp,
const uintptr_t *args,
size_t nr_args)
{
thr->tr_id = thr->tr_parent->t_next_thread_id++;
@@ -84,7 +86,7 @@ kern_status_t thread_init_user(
/* this context will be used by ml_user_return to jump to userspace
* with the specified instruction pointer and user stack */
ml_thread_prepare_user_context(ip, sp, &thr->tr_sp);
ml_thread_prepare_user_context(ip, sp, &thr->tr_sp, args, nr_args);
/* this context will be used by the scheduler and ml_thread_switch to
* jump to ml_user_return in kernel mode with the thread's kernel stack.
*/