aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel/vmem.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-07-04 19:25:12 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-07-04 19:25:12 +0300
commit07c2376702fb3d508d6ffad6b0ce93b83972ad6e (patch)
tree9ce46b000f8411fa86118645063b4df05d018dbf /arch/riscv64/kernel/vmem.c
parent66e7f184a925247bac51aae02d01483faa5454fc (diff)
downloadkmi-07c2376702fb3d508d6ffad6b0ce93b83972ad6e.tar.gz
kmi-07c2376702fb3d508d6ffad6b0ce93b83972ad6e.zip
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.
Diffstat (limited to 'arch/riscv64/kernel/vmem.c')
-rw-r--r--arch/riscv64/kernel/vmem.c11
1 files changed, 11 insertions, 0 deletions
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 */