diff --git a/src/sys/kernel/schedule.c b/src/sys/kernel/schedule.c index b26c673..7e670e5 100755 --- a/src/sys/kernel/schedule.c +++ b/src/sys/kernel/schedule.c @@ -30,8 +30,8 @@ #include #include -#ifndef NULL -#define NULL 0 +#ifndef CURRENT_CPU +#define CURRENT_CPU 0 #endif const uint32_t schedMagicNumber = 0x253B9CF9; @@ -70,6 +70,9 @@ } currentProc = -1; _current = &taskList[-1]; + + spinlockInit(&schedSpinlock); + setVector(timerInt, mVec, (dInt + dPresent + dDpl3)); } @@ -91,7 +94,10 @@ if (paniced == 1) while (1) ; - /* if ((currentProc == 1) && (taskList[2].status == RUNABLE)) + + spinlockLock(&schedSpinlock, CURRENT_CPU); + + /* if ((currentProc == 1) && (taskList[2].status == RUNABLE)) taskList[1].status = INACTIVE; */ i = currentProc + 1; @@ -116,6 +122,9 @@ GDT[4].descriptor.baseMed = ((memAddr >> 16) & 0xff); GDT[4].descriptor.baseHigh = (memAddr >> 24); //kprintf("Task: [%i][%i][%i]\n",_current->id,_current->tss.cr3,&_current->tss.cr3); + + spinlockUnlock(&schedSpinlock, CURRENT_CPU); + asm("ljmp $0x20,$0\n"); } }