diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:38:59 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:38:59 +0300 |
| commit | 7e828ec1e1479ff9a8afe845539d08ca0dfada5f (patch) | |
| tree | a227c58b30c99058fc10ff3caffeebca7dbd5913 /src/orphanage.c | |
| parent | 219c27d420fe0abe5515cefc2513c6fe60aafdf9 (diff) | |
| download | kmi-7e828ec1e1479ff9a8afe845539d08ca0dfada5f.tar.gz kmi-7e828ec1e1479ff9a8afe845539d08ca0dfada5f.zip | |
add orphan checking to timer and irq handling
Diffstat (limited to 'src/orphanage.c')
| -rw-r--r-- | src/orphanage.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/orphanage.c b/src/orphanage.c index e613e8b..3ca016e 100644 --- a/src/orphanage.c +++ b/src/orphanage.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: copyleft-next-0.3.1 */ /* Copyright 2024, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */ +#include <kmi/bkl.h> #include <kmi/assert.h> #include <kmi/orphanage.h> @@ -30,6 +31,7 @@ void unorphanize(struct tcb *t) struct tcb *init = get_tcb(1); reference_proc(init); + id_t old_rid = t->rid; t->rid = 1; t->pid = 1; t->eid = 1; @@ -41,15 +43,18 @@ void unorphanize(struct tcb *t) use_vmem(t->proc.vmem); alloc_stack(t); - clear_bits(t->state, TCB_ORPHAN); - assert(init->callback); - set_args3(t, 0, SYS_USER_ORPHANED, t->tid); + set_args4(t, 0, t->tid, SYS_USER_ORPHANED, old_rid); set_return(t, init->callback); t->callback = init->callback; - /** @todo release irqs, here or later? */ + /** @todo release irqs, here or later? Currently leaning towards later + * as they don't really take up any resources and the implementation + * doesn't make it too easy to search for a specific owner, we can just + * discard the IRQ if it turns out that the owner has been orphaned by + * that point. */ + bkl_unlock(); ret_userspace_fast(); unreachable(); } |
