Răsfoiți Sursa

:bug: 修复了进程由于异常被捕获后,其他进程无法被正常调度的问题

fslongjin 2 ani în urmă
părinte
comite
b97aaee746
3 a modificat fișierele cu 24 adăugiri și 23 ștergeri
  1. 1 1
      kernel/exception/entry.S
  2. 22 22
      kernel/exception/trap.c
  3. 1 0
      kernel/sched/sched.c

+ 1 - 1
kernel/exception/entry.S

@@ -53,7 +53,7 @@ Restore_all:
     popq %rax
     addq $0x10, %rsp // 弹出变量FUNC和errcode
     
-    sti
+    // sti
     iretq
 
 ret_from_exception:

+ 22 - 22
kernel/exception/trap.c

@@ -9,8 +9,8 @@
 void do_divide_error(struct pt_regs *regs, unsigned long error_code)
 {
     //kerror("do_divide_error(0)");
-    kerror("do_divide_error(0),\tError Code:%#18lx,\tRSP:%#18lx,\tRIP:%#18lx\t CPU:%d\n", error_code, regs->rsp, regs->rip, proc_current_cpu_id);
-
+    kerror("do_divide_error(0),\tError Code:%#18lx,\tRSP:%#18lx,\tRIP:%#18lx\t CPU:%d\t pid=%d\n", error_code, regs->rsp, regs->rip, proc_current_cpu_id, current_pcb->pid);
+    current_pcb->state = PROC_STOPPED;
     while (1)
         hlt();
 }
@@ -285,27 +285,27 @@ void do_virtualization_exception(struct pt_regs *regs, unsigned long error_code)
 
 void sys_vector_init()
 {
-    set_trap_gate(0, 1, divide_error);
-    set_trap_gate(1, 1, debug);
-    set_intr_gate(2, 1, nmi);
-    set_system_trap_gate(3, 1, int3);
-    set_system_trap_gate(4, 1, overflow);
-    set_system_trap_gate(5, 1, bounds);
-    set_trap_gate(6, 1, undefined_opcode);
-    set_trap_gate(7, 1, dev_not_avaliable);
-    set_trap_gate(8, 1, double_fault);
-    set_trap_gate(9, 1, coprocessor_segment_overrun);
-    set_trap_gate(10, 1, invalid_TSS);
-    set_trap_gate(11, 1, segment_not_exists);
-    set_trap_gate(12, 1, stack_segment_fault);
-    set_trap_gate(13, 1, general_protection);
-    set_trap_gate(14, 1, page_fault);
+    set_trap_gate(0, 0, divide_error);
+    set_trap_gate(1, 0, debug);
+    set_intr_gate(2, 0, nmi);
+    set_system_trap_gate(3, 0, int3);
+    set_system_trap_gate(4, 0, overflow);
+    set_system_trap_gate(5, 0, bounds);
+    set_trap_gate(6, 0, undefined_opcode);
+    set_trap_gate(7, 0, dev_not_avaliable);
+    set_trap_gate(8, 0, double_fault);
+    set_trap_gate(9, 0, coprocessor_segment_overrun);
+    set_trap_gate(10, 0, invalid_TSS);
+    set_trap_gate(11, 0, segment_not_exists);
+    set_trap_gate(12, 0, stack_segment_fault);
+    set_trap_gate(13, 0, general_protection);
+    set_trap_gate(14, 0, page_fault);
     // 中断号15由Intel保留,不能使用
-    set_trap_gate(16, 1, x87_FPU_error);
-    set_trap_gate(17, 1, alignment_check);
-    set_trap_gate(18, 1, machine_check);
-    set_trap_gate(19, 1, SIMD_exception);
-    set_trap_gate(20, 1, virtualization_exception);
+    set_trap_gate(16, 0, x87_FPU_error);
+    set_trap_gate(17, 0, alignment_check);
+    set_trap_gate(18, 0, machine_check);
+    set_trap_gate(19, 0, SIMD_exception);
+    set_trap_gate(20, 0, virtualization_exception);
     // 中断号21-31由Intel保留,不能使用
     
     

+ 1 - 0
kernel/sched/sched.c

@@ -75,6 +75,7 @@ void sched_cfs()
             }
         }
         // kdebug("before switch, next.rip = %#018lx\tnext->gs=%#018lx", proc->thread->rip, proc->thread->gs);
+        // kdebug("currentpcb=%#018lx", (uint64_t)current_pcb);
         process_switch_mm(proc);
         switch_proc(current_pcb, proc);
     }