Newer
Older
#include <scheduler.h>
#include <priority-q.h>
#include <td.h>
#include <bwio.h>
// int schedulerInit() {
// return 0;
// } // add the IDLE task with lowest priority and first USER task maybe
//extern int PushToTDPQ(TDPQ* PQ, TD* Task);
int pushToScheduler (KernelStruct* Colonel, TD* Task) {
int returncode= PushToTDPQ(&(Colonel->ArrayPQ)[Task->TaskPriority],Task);
//bwprintf(COM2,"return code of push onto tdpq %d\n\r",returncode);
return returncode;
}
TD* getNextTaskScheduler (KernelStruct* Colonel) {
TD *Task;
int i = 0;
TDPQ *PQ;
for(;i<MAX_NUM_PRIORITY;i++){
PQ = &(Colonel->ArrayPQ)[i];
if(TDPQReady(PQ) && PQ->Length >0){
Task = TDPQGetStart(PQ);
while (Task->TaskState != Ready) {
TDPQPopStart(PQ);
pushToScheduler(Colonel, Task);
Task = TDPQGetStart(PQ);
}