private Job PredictAssignTask() { Job temp = null; if (Current != null) { temp = Current.Clone(); } if (ReadyList.Count() > 0) { // Assign a task if we dont have one if (temp == null) { temp = ReadyList.Peek().Clone(); } // Preempt the current task if the awaiting task's deadline is lower //else if (ReadyList.Peek().PriorityDeadline < Current.PriorityDeadline) else if (ReadyList.Peek().PriorityDeadline < temp.PriorityDeadline) { //ReadyList.Enqueue(Current); temp = ReadyList.Peek().Clone(); } } return(temp); }
private void AssignTask() { if (ReadyList.Count() > 0) { // Assign a task if we dont have one if (Current == null) { Current = ReadyList.Dequeue(); } // Preempt the current task if the awaiting task's deadline is lower //else if (ReadyList.Peek().PriorityDeadline < Current.PriorityDeadline) else if (ReadyList.Peek().PriorityDeadline < Current.PriorityDeadline) { ReadyList.Enqueue(Current); Current = ReadyList.Dequeue(); } } }
//TODO: Does this work correctly with an empty taskset? /// <summary> /// This method executes the current event if is set. /// It also sets the upcoming event based on the readylist/waiting list. /// </summary> /// <param name="debug">Indicates if the ExecutionTrace should be built.</param> public void TriggerEvent(bool debug) { int next = Int32.MaxValue; ReleaseTasks(Event.Cycle); if (Current == null) { if (ReadyList.Count() > 0) { if ((Event.Cycle % Hyperperiod) == 0) { int offset = Separation[ReadyList.Peek().Cil]; next = Event.Cycle + offset; } else { Current = ReadyList.Dequeue(); next = Current.NextEvent(Event.Cycle, MacroTick); } } else if (WaitingList.Count() > 0) { next = WaitingList.Peek().Release; } } else { bool finalExecutionSlice = Current.FinalEvent(MacroTick); Current.Execute(Event.Cycle, debug, MacroTick); next = Current.NextEvent(Event.Cycle, MacroTick); int offset = 0; if (ReadyList.Count() > 0) { Job possibleJob = ReadyList.Peek(); if (possibleJob.Cil != Current.Cil) { offset = Separation[possibleJob.Cil]; } if (finalExecutionSlice) { WaitingList.Enqueue(Current); Current = null; next = Event.Cycle + offset; } else if ((possibleJob.PriorityDeadline + offset) < Current.PriorityDeadline) { ReadyList.Enqueue(Current); Current = null; next = Event.Cycle + offset; } } else { if (finalExecutionSlice) { WaitingList.Enqueue(Current); Current = null; foreach (var item in Separation) { if (offset < item.Value) { offset = item.Value; } } next = Event.Cycle + offset; } } ReleaseTasks(Event.Cycle); } Event.Cycle = next; }