diff options
author | Marvin Borner | 2021-06-08 21:13:33 +0200 |
---|---|---|
committer | Marvin Borner | 2021-06-08 21:13:33 +0200 |
commit | 24ce56cccb6f179f8c6ed9ad82e6afb871aabf80 (patch) | |
tree | ec3283601331b6def7218c7b39386d6bb25bcd5b /kernel/features | |
parent | f7890c4b16b5d817db286119ac0a88630c3a1cf9 (diff) |
Process exit improvements
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/mm.c | 6 | ||||
-rw-r--r-- | kernel/features/proc.c | 12 | ||||
-rw-r--r-- | kernel/features/syscall.c | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 0137256..736a5a4 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -75,7 +75,7 @@ static void page_fault_handler(u32 esp) // Check error code const char *type = (frame->err_code & 1) ? "present" : "non-present"; const char *operation = (frame->err_code & 2) ? "write" : "read"; - const char *super = (frame->err_code & 4) ? "User" : "Super"; + const char *super = (frame->err_code & 4) ? "user" : "super"; // Check cr2 address (virtual and physical) u32 vaddr; @@ -86,8 +86,8 @@ static void page_fault_handler(u32 esp) // Print! - printf("%s process tried to %s a %s page at [vaddr=%x; paddr=%x]\n", super, operation, type, - vaddr, paddr); + printf("Process in %s-state tried to %s a %s page at [vaddr=%x; paddr=%x]\n", super, + operation, type, vaddr, paddr); if (proc && vaddr > proc->stack.user_ptr - PROC_STACK_SIZE - PAGE_SIZE && vaddr < proc->stack.user_ptr + PAGE_SIZE) diff --git a/kernel/features/proc.c b/kernel/features/proc.c index b686823..70e3666 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -156,9 +156,10 @@ void proc_state(struct proc *proc, enum proc_state state) // else: Nothing to do! } -void proc_exit(struct proc *proc, s32 status) +void proc_exit(s32 status) { - assert(proc != idle_proc->data); + struct proc *proc = proc_current(); + assert(proc && proc != idle_proc->data); struct node *running = list_first_data(proc_list_running, proc); if (!running || !list_remove(proc_list_running, running)) { @@ -166,10 +167,9 @@ void proc_exit(struct proc *proc, s32 status) assert(blocked && list_remove(proc_list_blocked, blocked)); } - if (current->data == proc) { - memory_switch_dir(virtual_kernel_dir()); - current = NULL; - } + // Force switch to other process + memory_switch_dir(virtual_kernel_dir()); + current = NULL; printf("Process %s (%d) exited with status %d (%s)\n", proc->name[0] ? proc->name : "UNKNOWN", proc->pid, status, diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 93355db..6e43caa 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -89,14 +89,14 @@ static u32 syscall_handler(u32 esp) struct proc *proc = proc_make(PROC_PRIV_NONE); frame->eax = (u32)elf_load(path, proc); if (frame->eax != EOK) - proc_exit(proc, -frame->eax); + panic("NOT IMPLEMENTED\n"); // TODO: Implement exec path/etc verify else proc_yield(); break; } case SYS_EXIT: { frame->eax = EOK; - proc_exit(proc_current(), (s32)frame->ebx); + proc_exit((s32)frame->ebx); break; } case SYS_YIELD: { |