diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index aff65db..827a0e9 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -30,10 +30,6 @@ #ifndef _SCHED_H #define _SCHED_H -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include @@ -66,8 +62,6 @@ uInt32 gid; uInt32 uid; uInt16 usedMath; - uInt16 nice; - uInt32 timeSlice; tty_term *term; } kTask_t; @@ -89,19 +83,18 @@ void schedEndTask(pidType pid); kTask_t *schedNewTask(); kTask_t *schedFindTask(uInt32 id); -int deleteTask(uInt32); extern kTask_t *_current; extern kTask_t *_usedMath; -#ifdef __cplusplus -} -#endif #endif /*** $Log$ + Revision 1.26 2004/09/07 21:54:38 reddawg + ok reverted back to old scheduling for now.... + Revision 1.20 2004/08/09 12:58:05 reddawg let me know when you got the surce diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 5b467b1..3c625ea 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -71,79 +71,27 @@ ************************************************************************/ -int -sched_init() -{ - int i; +int sched_init() { + taskList = (kTask_t *)kmalloc(sizeof(kTask_t)); + + taskList->id = nextID++; - for (i = 0; i < MAXPRIOLEVELS; i++) { - prioQueue_t *tmpPrioQ; - kTask_t *tmpTask; - - tmpPrioQ = (prioQueue_t *)kmalloc(sizeof(prioQueue_t)); - tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); - - if (tmpPrioQ == 0x0) { - kpanic("Error: schedInit() - kmalloc failed trying to initialize a prioQueue_t struct\n"); - return(0x1); - } - - if (tmpTask == 0x0) { - kpanic("Error: schedInit() - kmalloc failed trying to initialize a kTask_t struct\n"); - return(0x1); - } - - tmpPrioQ->start = tmpTask; - tmpPrioQ->end = tmpTask; - tmpPrioQ->prio = i; - prioLevels[i] = tmpPrioQ; - - tmpTask->prev = 0x0; - tmpTask->next = 0x0; - tmpTask->id = -1; - tmpTask->state = PLACEHOLDER; - tmpTask->nice = i; - tmpTask->timeSlice = systemVitals->dQuantum; - - /* Linking the previous placeholder with the current one */ - if (i > 0) { - prioLevels[i - 1]->start->next = tmpTask; - tmpTask->prev = prioLevels[i - 1]->end; - } - - if (0x0 == prioQStart) { - tmpPrioQ->next = 0x0; - tmpPrioQ->prev = 0x0; - prioQStart = prioQEnd = tmpPrioQ; - } else { - tmpPrioQ->prev = prioQEnd; - prioQEnd->next = tmpPrioQ; - tmpPrioQ->next = 0x0; - prioQEnd = tmpPrioQ; - } - } - - taskList = prioLevels[0]->start; - _current = prioLevels[MAXPRIOLEVELS/2]->start; - _currentQueue = prioLevels[0]; - - nextID++; - - /* Print out information on scheduler */ - kprintf("sched0 solar 0.2.1 - Address: [0x%X]\n", prioQStart); + /* Print out information on scheduler */ + kprintf("sched0 - Address: [0x%X]\n", taskList); - /* Return so we know everything went well */ - return(0x0); -} + /* Return so we know everything went well */ + return(0x0); + } void sched(){ uInt32 memAddr = 0x0; kTask_t *tmpTask = 0x0; + tmpTask = _current->next; schedStart: /* Yield the next task from the current prio queue */ - for (tmpTask = _current->next; tmpTask; tmpTask = tmpTask->next) { + for (;tmpTask != 0x0; tmpTask = tmpTask->next) { if (tmpTask->state > 0x0) { _current = tmpTask; if (_current->state == FORK) @@ -155,12 +103,9 @@ /* Finished all the tasks, restarting the list */ if (0x0 == tmpTask) { - _current = taskList; + tmpTask = taskList; goto schedStart; } - - /* Setting the timeslice this task is allowed to run */ - systemVitals->quantum = _current->timeSlice; if (_current->state > 0x0) { @@ -173,52 +118,32 @@ ubixGDT[4].descriptor.baseHigh = (memAddr >> 24); ubixGDT[4].descriptor.access = '\x89'; asm("ljmp $0x20,$0\n"); + asm("sti"); } return; } -kTask_t * -schedNewTask() -{ - kTask_t *tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); +kTask_t *schedNewTask() { + kTask_t *tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); + if (tmpTask == 0x0) + kpanic("Error: schedNewTask() - kmalloc failed trying to initialize a new task struct\n"); - if (tmpTask == 0x0) { - kpanic("Error: schedNewTask() - kmalloc failed trying to initialize a new task struct\n"); - return(0x0); - } - - //spinLock(&schedTaskSpinLock); - /* Filling in tasks attrs */ - tmpTask->usedMath = 0x0; - tmpTask->id = ++nextID; - tmpTask->state = NEW; - tmpTask->nice = _current->nice; + /* Filling in tasks attrs */ + tmpTask->usedMath = 0x0; + tmpTask->id = nextID++; + tmpTask->state = NEW; - tmpTask->timeSlice = systemVitals->dQuantum * tmpTask->nice; - tmpTask->oInfo.cwd = (char *)kmalloc(1024); - assert(tmpTask->oInfo.cwd); - - /* Are we adding a task at the end of the last prio queue? */ - if (0x0 == prioLevels[_current->nice]->next) - tmpTask->next = 0x0; - else - tmpTask->next = prioLevels[_current->nice + 1]->start; - - tmpTask->prev = prioLevels[_current->nice]->end; - - /* - * Inserting the task at the end of the proper prio queue; - * this gives me the feeling of O(1) for task insertion - */ - prioLevels[_current->nice]->end->next = tmpTask; - prioLevels[_current->nice]->end = tmpTask; - - //spinUnlock(&schedTaskSpinLock); - return(tmpTask); -} + tmpTask->oInfo.cwd = (char *)kmalloc(1024); + tmpTask->next = taskList; + tmpTask->prev = 0x0; + taskList->prev = tmpTask; + taskList = tmpTask; + + return(tmpTask); + } /* @@ -327,6 +252,9 @@ /*** $Log$ + Revision 1.49 2004/09/07 22:05:59 reddawg + only changes I have to contribute + Revision 1.48 2004/09/07 21:54:38 reddawg ok reverted back to old scheduling for now....