void YKScheduler(bool saveContext) { /* If (current task.priority != highestPriorityReadyTask.priority) Call Dispatcher to run highest priority ready task. */ if (YKCurTask != YKRdyList) // We don't need to look to the priority because it is a pointer if (YKRun) YKDispatcher(); }
//2.5 void YKScheduler(int contextSaved) { /* Determines the highest priority ready task */ TCBptr next; if(!started) return; next = peak(YKRdyList); if(runningTask != NULL && runningTask->priority != next->priority){ YKEnterMutex(); YKCtxSwCount++; if(contextSaved == 0) { YKSaveContext(); } YKDispatcher(next); } else if (runningTask == NULL){ YKDispatcher(next); } }
void YKScheduler(void) { if (YKCurrTask != YKRdyList) { // going to change contexts /*print_ready_list(); printString("DispatchingTask: "); printInt(YKRdyList); printNewLine(); printString("CurTask: "); printInt(YKCurrTask); printNewLine(); int count; YKEnterMutex(); printNewLine(); printString("Block List:"); printNewLine(); count = print_delay_list(); printString("Ready List:"); printNewLine(); count += print_ready_list(); if (count != 6) YKErrorFlag = 1; YKExitMutex();*/ YKDispatcher(); } }
void YKScheduler(int saveContext){ YKEnterMutex(); if(YKRdyList != YKCurTask){ YKCtxSwCount++; YKDispatcher(saveContext); } YKExitMutex(); }
//Scheduler & Dispatcher ------------------------------------------------------------------------------ void YKScheduler(int saveContext) { //call the dispatcher if the next task isn't already the one running if(curTask->priority != YKReadyList->priority) {; YKDispatcher(saveContext); } YKExitMutex(); }
void YKScheduler(void){ //printString("YKScheduler\n"); //Peek the top ready task, if different from current task //call dispatcher if(curTCB == null) { YKCtxSwCount++; YKDispatcher(1); //first run } else if(curTCB != readyHead) { YKCtxSwCount++; if(curTCB->runCount == 0) { curTCB->runCount = curTCB->runCount + 1; YKDispatcher(2); } else { curTCB->runCount = curTCB->runCount + 1; YKDispatcher(0); } } }
void YKScheduler(void) { TCB* readyTask; YKEnterMutex(); if (kernelState == K_BLOCKED) return; readyTask = peekPriorityQueue(&readyQueue); if (readyTask == null) exit(READY_QUEUE_EMPTY); if (readyTask != currentTask) { currentTask = readyTask; currentTask->state = T_READY; YKCtxSwCount++; readyTask->state = T_RUNNING; YKDispatcher(readyTask); YKExitMutex(); return; } YKExitMutex(); return; }
//Scheduler & Dispatcher --------------------------------------------------------------------- void YKScheduler(int saveContext) { // Move any nonzero tasks to the delay que // Grab highest priority TCB // Start TCB w/ the Dispatcher //printString("Scheduler\n\r"); //call the dispatcher; //printAllLists(); if(curTask->priority != YKReadyList->priority) { //printString("CALLING DISPATCHER\n\r"); //curTask = YKReadyList; //YKExitMutex(); YKDispatcher(saveContext); } YKExitMutex(); //printString("EXIT SCHEDULER\n\r"); }