summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-03-27 17:12:56 -0400
committerMac Mollison <mollison@cs.unc.edu>2010-03-27 17:12:56 -0400
commit841902573bb00724b9ab3f2938a60a1b17298618 (patch)
treebfe01c5d091f171670d82a426f7ee57e3e4caa83
parentcf8cbbaf8f96bcda3c759583cc5d8c892f7067f0 (diff)
Very minor cleanup in gedf_test.py
-rw-r--r--unit_trace/gedf_test.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/unit_trace/gedf_test.py b/unit_trace/gedf_test.py
index cf66142..993e99a 100644
--- a/unit_trace/gedf_test.py
+++ b/unit_trace/gedf_test.py
@@ -18,11 +18,10 @@ import sys
18 18
19def gedf_test(stream): 19def gedf_test(stream):
20 20
21 # Two lists to model the system: tasks occupying a CPU and tasks eligible 21 # System model
22 # to do so. Also, m = the number of CPUs. 22 eligible = [] # Tasks eligible
23 eligible = [] 23 on_cpu = [] # Tasks running
24 on_cpu = [] 24 m = None # CPUs
25 m = None
26 25
27 # Time of the last record we saw. Only run the G-EDF test when the time 26 # Time of the last record we saw. Only run the G-EDF test when the time
28 # is updated. 27 # is updated.
@@ -59,13 +58,12 @@ def gedf_test(stream):
59 # Move a Job from the eligible queue to on_cpu 58 # Move a Job from the eligible queue to on_cpu
60 elif record.type_name == 'switch_to': 59 elif record.type_name == 'switch_to':
61 pos = _find_job(record,eligible) 60 pos = _find_job(record,eligible)
62 try: 61 if pos is None:
63 job = eligible[pos]
64 except TypeError:
65 msg = "Event %d tried to switch to a job that was not eligible\n" 62 msg = "Event %d tried to switch to a job that was not eligible\n"
66 msg = msg % (record.id) 63 msg = msg % (record.id)
67 sys.stderr.write(msg) 64 sys.stderr.write(msg)
68 exit() 65 exit()
66 job = eligible[pos]
69 del eligible[pos] 67 del eligible[pos]
70 on_cpu.append(job) 68 on_cpu.append(job)
71 69
@@ -84,6 +82,12 @@ def gedf_test(stream):
84 # been marked as complete, remove it from the model. 82 # been marked as complete, remove it from the model.
85 elif record.type_name == 'switch_away': 83 elif record.type_name == 'switch_away':
86 pos = _find_job(record,on_cpu) 84 pos = _find_job(record,on_cpu)
85 if pos is None:
86 msg = ("Event %d tried to switch to switch away a job" +
87 " that was not running\n")
88 msg = msg % (record.id)
89 sys.stderr.write(msg)
90 exit()
87 job = on_cpu[pos] 91 job = on_cpu[pos]
88 del on_cpu[pos] 92 del on_cpu[pos]
89 if job.is_complete == False: 93 if job.is_complete == False: