Scheduler
miss.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import matplotlib.pyplot as plt
3 import sys
4 import itertools
5 def main():
6  filename = "scratch/configuration.confdeadlineMissesReport.txt"
7  if (len(sys.argv) > 1):
8  filename = sys.argv[1]
9  with open(filename) as f:
10  print f.readline()
11  entries = ((float(elem) for elem in line.split(":")) for line in f)
12  (time, pid) = itertools.izip(*entries)
13 
14  missNumber(time);
15 
16  plt.suptitle(filename, fontsize=14, fontweight='bold')
17  plt.plot(time, pid, 'ro')
18  plt.axis([-1,max(time)+1,-1,max(pid) + 1])
19  plt.show()
20 
21 
22 cutoffTime = 1800000;
23 
24 def missNumber(time):
25  if (len(time) == 0):
26  print "No deadline misses";
27  return;
28  if (time[len(time)-1] <= cutoffTime):
29  print "No deadline misses";
30  return;
31  number = str(recursiveSearch(time))
32  print "number of misses is", number
33 #The goal is to count the number of deadline misses that occur after the cutoff time.
34 #the cutoff time is defined close to the end of the timulation time (eg at 90% of the total simulation time).
35 #To count, we use a dichotomic search.
36 #Maybe ther eexist a built in python function to do it, but I didn't find it...
37 def recursiveSearch(timeArray):
38  if (len(timeArray) == 0):
39  return 0;
40  if (len(timeArray) == 1):
41  if (timeArray[0] < cutoffTime):
42  return 0;
43  else:
44  return 1;
45  if (timeArray[len(timeArray)/2] < cutoffTime):
46  return recursiveSearch(timeArray[len(timeArray)/2:len(timeArray)-1])
47  else:
48  return recursiveSearch(timeArray[0:len(timeArray)/2-1]) + len(timeArray)/2
49 
50 
51 if __name__ == '__main__':
52  main()
53 
54 
55 
56 
57 
def main()
Definition: miss.py:5
def missNumber(time)
Definition: miss.py:24
def recursiveSearch(timeArray)
Definition: miss.py:37