diff --git a/kinclude/ecall.c b/kinclude/ecall.c index e54d478..02abaa2 100644 --- a/kinclude/ecall.c +++ b/kinclude/ecall.c @@ -202,7 +202,12 @@ void init_ecall_table() void handle_exception(int ecode, int mtval) { - //TODO: handle exceptions well - dbgln("exception encountered!", 17); - __asm__ ("ebreak"); + // kill off offending process + ProcessControlBlock* pcb = get_current_process(); + pcb->status = PROC_DEAD; + pcb->exit_code = -99; + destroy_process(pcb); + + // run the next process + scheduler_run_next(); } diff --git a/kinclude/sched.c b/kinclude/sched.c index 5335282..f01ddbe 100644 --- a/kinclude/sched.c +++ b/kinclude/sched.c @@ -96,7 +96,7 @@ ProcessControlBlock* scheduler_select_free() pcb->waiting_for_process->status == PROC_DEAD) { // the requested process exited, so we can set the status code and pcb->regs[REG_A0] = pcb->waiting_for_process->exit_code; - pcb->regs[REG_A0+1] = 0; + pcb->regs[REG_A0 + 1] = 0; pcb->status = PROC_RDY; return pcb; }