From 94d3cbfcc66c276206d405075c5966fdb0450959 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 6 Jun 2020 18:14:58 +0200 Subject: Progressed in embedded assignments --- sem4/embedded/eksamnen/schedsolver.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sem4/embedded/eksamnen/schedsolver.rb') diff --git a/sem4/embedded/eksamnen/schedsolver.rb b/sem4/embedded/eksamnen/schedsolver.rb index ca2e619..bf9c467 100755 --- a/sem4/embedded/eksamnen/schedsolver.rb +++ b/sem4/embedded/eksamnen/schedsolver.rb @@ -78,12 +78,14 @@ class Scheduler curtask = nextTask(index) new = {:task => curtask, :remain => []} @tasks.each_with_index do |task, i| + # Check for deadline miss + intoperiod = index % task[:period] + if intoperiod >= task[:deadline] && @states.last[:remain][i] > 0 + puts "Deadline missed in task #{i}" + exit + end # Check if start of new period if index % task[:period] == 0 - if @states.last and @states.last[:remain][i] > 0 - puts "Deadline missed in task #{i}" - exit - end new[:remain] << task[:complete] else new[:remain] << @states.last[:remain][i] -- cgit v1.2.3