From 07c2376702fb3d508d6ffad6b0ce93b83972ad6e Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 4 Jul 2024 19:25:12 +0300 Subject: add zombie and orphan threads + Should write this down somewhere but the idea is that when a process gets killed, it frees all the memory it can, making all threads within that process orphans. Orphaned threads are assigned to the init process, which will generally call exit() on each one. Zombie threads are threads that own some bit of shared data, and whose reference count is above zero. They may not be swapped to or called, even though they take up space in thread map and reserve their thread ID. --- arch/riscv64/kernel/vmem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'arch/riscv64/kernel/vmem.c') diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c index d00a6c9..f87c76d 100644 --- a/arch/riscv64/kernel/vmem.c +++ b/arch/riscv64/kernel/vmem.c @@ -512,6 +512,17 @@ void setup_rpc_stack(struct tcb *t) t->arch.rpc_idx = 511; } +void destroy_rpc_stack(struct tcb *t) +{ + size_t pages = order_size(MM_O1) / BASE_PAGE_SIZE; + for (size_t i = 0; i < pages; ++i) { + pm_t page; enum mm_order order; + stat_vpage(t->rpc.vmem, RPC_STACK_BASE + BASE_PAGE_SIZE * i, + &page, &order, NULL); + free_page(page, order); + } +} + vm_t rpc_position(struct tcb *t) { /** @todo we assume rpc_idx is updated on every segfault of the rpc stack */ -- cgit v1.3