diff options
author | Marvin Borner | 2021-03-21 14:31:08 +0100 |
---|---|---|
committer | Marvin Borner | 2021-03-21 14:31:08 +0100 |
commit | 3d0c30e6697b2b6ae77a03adefa2a8b81ebe4d92 (patch) | |
tree | aaa59a9fa43ddf50dafcc89bf979fb20de351941 /kernel/features/proc.c | |
parent | 09c3bdb186868204cb03d457244e05e12eb685d6 (diff) |
Cleaner shared memory implementation
Diffstat (limited to 'kernel/features/proc.c')
-rw-r--r-- | kernel/features/proc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 88c477f..624a835 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -140,15 +140,21 @@ void proc_exit(struct proc *proc, s32 status) iterator = iterator->next; } + assert(found); + if (memcmp(proc, current->data, sizeof(*proc)) == 0) current = NULL; - if (found) - printf("Process %s (%d) exited with status %d (%s)\n", - proc->name[0] ? proc->name : "UNKNOWN", proc->pid, status, - status == 0 ? "success" : "error"); + printf("Process %s (%d) exited with status %d (%s)\n", + proc->name[0] ? proc->name : "UNKNOWN", proc->pid, status, + status == 0 ? "success" : "error"); + stack_destroy(proc->messages); + list_destroy(proc->memory); // TODO: Decrement memory ref links virtual_destroy_dir(proc->page_dir); + + free(proc); + proc_clear_quantum(); // TODO: Add quantum to each process struct? // The caller has to yield itself @@ -250,6 +256,7 @@ struct proc *proc_make(enum proc_priv priv) proc->pid = current_pid++; proc->priv = priv; proc->messages = stack_new(); + proc->memory = list_new(); proc->state = PROC_RUNNING; if (priv == PROC_PRIV_KERNEL) |