diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-30 00:57:33 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-30 00:57:33 +0200 |
| commit | 44a73ecab6e91519627786a5101cd4f1a2f2b0d7 (patch) | |
| tree | f5c811050a4d5ee832f5883c4d0c27efddd60817 /src/uapi/proc.c | |
| parent | 5976ad390a15726c3ddfacf8c8b282c8350f9554 (diff) | |
| download | kmi-44a73ecab6e91519627786a5101cd4f1a2f2b0d7.tar.gz kmi-44a73ecab6e91519627786a5101cd4f1a2f2b0d7.zip | |
most of the way to passing tests
Diffstat (limited to 'src/uapi/proc.c')
| -rw-r--r-- | src/uapi/proc.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/uapi/proc.c b/src/uapi/proc.c index b010220..3b65a04 100644 --- a/src/uapi/proc.c +++ b/src/uapi/proc.c @@ -38,19 +38,18 @@ SYSCALL_DEFINE5(create)(struct tcb *t, sys_arg_t func, if (!c) return_args1(t, ERR_OOMEM); - /** @todo there's quite a bit of overlap between this and what - * core_bringup() is doing, might separate this out into its own - * function? */ - if (alloc_stack(c)) { - destroy_thread(c); - return_args1(t, ERR_OOMEM); - } + /* temporarily jump into new thread memory to set arguments */ + use_vmem(c->rpc.vmem); + /* this visit is likely not the cheapest thing in the universe, are + * there ways to speed up thread creation? */ set_thread(c); - set_ret5(c, c->tid, d0, d1, d2, d3); set_return(c, func); + /* return back */ + use_vmem(t->rpc.vmem); + c->notify_id = t->notify_id; return_args1(t, c->tid); } @@ -81,9 +80,13 @@ SYSCALL_DEFINE0(fork)(struct tcb *t) if (!n) return_args1(t, ERR_OOMEM); + /* again, probably not fantastic that we're jumping between address + * spaces like this */ + use_vmem(n->rpc.vmem); /* prepare args for when we eventually swap to the new proc, giving * parent ID as third return value */ set_args2(n, 0, get_eproc(t)->pid); + use_vmem(t->rpc.vmem); n->notify_id = c->notify_id; return_args1(t, n->pid); @@ -189,6 +192,10 @@ SYSCALL_DEFINE2(spawn)(struct tcb *t, sys_arg_t bin, sys_arg_t interp) */ static void swap(struct tcb *t, struct tcb *s) { + /* set return value for current thread, important to do first since + * use_tcb() switches the register slots, really easy to miss, not great */ + set_args1(t, OK); + /* switch over to new thread */ use_tcb(s); @@ -201,9 +208,6 @@ static void swap(struct tcb *t, struct tcb *s) return; } - /* set return value for current thread */ - set_args1(t, OK); - /* handle possible queued notification */ if (s->notify_flags) notify(s, 0); |
