ecall module now kills processes which trigger an exception

This commit is contained in:
Anton Lydike 2021-08-30 20:11:07 +02:00
parent b08198d166
commit 14c2dd95a6
2 changed files with 9 additions and 4 deletions

View File

@ -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();
}

View File

@ -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;
}