public static void ChangeDynamicPrioritiesToMeetDeadlines(List <Task> tasks) { PriorityAssigner.AssignDynamicPriorities(tasks); //Dynamic Priority should be at least the same as the static priority var maximumPriority = tasks.Max(o => o.StaticPriority); var canSystemBeMadeScheduable = true; while (!FeasibilityUsingResponseTimeAnalysis(tasks) && canSystemBeMadeScheduable) { var tasksThatMissTheirDeadlines = tasks.Where(o => o.WorstCaseRunTime > o.Deadline).ToList(); foreach (var task in tasksThatMissTheirDeadlines) { if (task.DynamicPriority < maximumPriority) { task.DynamicPriority += 1; } else { canSystemBeMadeScheduable = false; } } } }
/// <summary> /// This function takes a list of tasks and assign them with a static priority after the Deadline Monotonic principle /// It changes the dynamic priorities of the task to see if the task set can be made scheduleable /// It thereafter calculate the different times /// </summary> /// <param name="tasks"></param> /// <returns></returns> public static bool DoesFeasibleScheduleExist(List <Task> tasks) { PriorityAssigner.DeadlineMonotonicPriorityAssignment(tasks); ChangeDynamicPrioritiesToMeetDeadlines(tasks); return(tasks.TrueForAll(o => o.WorstCaseRunTime <= o.Deadline)); }