diff --git a/src/sys/kernel/schedule.c b/src/sys/kernel/schedule.c index 21144de..b26c673 100755 --- a/src/sys/kernel/schedule.c +++ b/src/sys/kernel/schedule.c @@ -27,12 +27,16 @@ #include #include #include +#include +#include #ifndef NULL #define NULL 0 #endif const uint32_t schedMagicNumber = 0x253B9CF9; +spinlock_t schedSpinlock; + int currentProc = -1; struct taskStruct *taskList = (struct taskStruct *)0xE0000000; @@ -41,6 +45,16 @@ extern union descriptorTableunion GDT[7]; extern int testVal; +int switches = 0; +uint8_t paniced = 0; + +void kpanic(char * mess) +{ + kprintf(mess); + paniced = 1; + schedule(); +} + /* Initialize Scheduler */ void initScheduler(void) { int i; @@ -73,6 +87,12 @@ void schedule() { int i,proc = -1,memAddr; outportByte(0x20, 0x20); + + if (paniced == 1) + while (1) + ; + /* if ((currentProc == 1) && (taskList[2].status == RUNABLE)) + taskList[1].status = INACTIVE; */ i = currentProc + 1; while ((taskList[i].status != RUNABLE) && (taskList[i].status != ACTIVE)) @@ -82,6 +102,10 @@ } proc = i; if (proc != -1) { + if (taskList[currentProc].status == ACTIVE) + { + taskList[currentProc].status = RUNABLE; + } currentProc = proc; _current = &taskList[proc]; taskList[proc].status = ACTIVE;