1 package DEOS; 20 21 24 class ProcessConstraint { 25 int remainingNormalizedUtilization; 26 int initialNormalizedUtilization; 27 28 public ProcessConstraint (int theUtilization) { 29 initialNormalizedUtilization = theUtilization; 31 remainingNormalizedUtilization = theUtilization; 32 } 33 34 public static int CPUTimeToNormalizedUtilization (int CPUTime, 35 int periodIndex) { 36 int ticksPerPeriod = (Registry.periodDurationInMicroSecs(periodIndex) / Registry.periodDurationInMicroSecs(0)); 37 38 return CPUTime / ticksPerPeriod; 42 } 43 44 public boolean allocateCPUForThread (int CPUTime, int periodIndex, 45 boolean isISR) { 46 int normalizedThreadUtilization = CPUTimeToNormalizedUtilization(CPUTime, 47 periodIndex); 48 49 if (normalizedThreadUtilization > remainingNormalizedUtilization) { 53 return false; } 55 56 remainingNormalizedUtilization -= normalizedThreadUtilization; 57 58 return true; 59 } 60 61 public void deallocateCPUForThread (int CPUTime, int periodIndex) { 62 remainingNormalizedUtilization += CPUTimeToNormalizedUtilization(CPUTime, 63 periodIndex); 64 } 65 66 public int oneHundredPercentUtilization () { 67 return Registry.periodDurationInMicroSecs(0); 68 } 69 } | Popular Tags |