summaryrefslogtreecommitdiffstats
path: root/unit_trace/gedf_test.py
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-04-03 23:05:23 -0400
committerMac Mollison <mollison@cs.unc.edu>2010-04-03 23:05:23 -0400
commit808ff90c55db21813967af8a814b61f520fdaff7 (patch)
tree2cea4e6bfe33972fb9d9bec1a2440bde0ff37967 /unit_trace/gedf_test.py
parent8e177eeb507e19ed82685ec598611180ec869ff0 (diff)
Rename 'eligible' to 'off_cpu'
This much more accurately captures what is going on and should greatly reduce confusion
Diffstat (limited to 'unit_trace/gedf_test.py')
-rw-r--r--unit_trace/gedf_test.py53
1 files changed, 27 insertions, 26 deletions
diff --git a/unit_trace/gedf_test.py b/unit_trace/gedf_test.py
index d4586ce..478a852 100644
--- a/unit_trace/gedf_test.py
+++ b/unit_trace/gedf_test.py
@@ -19,8 +19,8 @@ import sys
19def gedf_test(stream): 19def gedf_test(stream):
20 20
21 # System model 21 # System model
22 eligible = [] # Tasks eligible 22 on_cpu = [] # Tasks on a CPU
23 on_cpu = [] # Tasks running 23 off_cpu = [] # Tasks not on a CPU
24 m = None # CPUs 24 m = None # CPUs
25 25
26 # 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
@@ -45,26 +45,27 @@ def gedf_test(stream):
45 # so we only check when the time has moved forward) 45 # so we only check when the time has moved forward)
46 # Also, need to update the first_event_this_timestamp variable 46 # Also, need to update the first_event_this_timestamp variable
47 if last_time is not None and last_time != record.when: 47 if last_time is not None and last_time != record.when:
48 errors = _gedf_check(eligible,on_cpu,last_time,m, 48 errors = _gedf_check(off_cpu,on_cpu,last_time,m,
49 first_event_this_timestamp) 49 first_event_this_timestamp)
50 first_event_this_timestamp = record.id 50 first_event_this_timestamp = record.id
51 for error in errors: 51 for error in errors:
52 yield error 52 yield error
53 53
54 # Add a newly-released Job to the eligible queue 54 # Add a newly-released Job to the off_cpu queue
55 if record.type_name == 'release': 55 if record.type_name == 'release':
56 eligible.append(Job(record)) 56 off_cpu.append(Job(record))
57 57
58 # Move a Job from the eligible queue to on_cpu 58 # Move a Job from the off_cpu queue to on_cpu
59 elif record.type_name == 'switch_to': 59 elif record.type_name == 'switch_to':
60 pos = _find_job(record,eligible) 60 pos = _find_job(record,off_cpu)
61 if pos is None: 61 if pos is None:
62 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 on the"
63 msg += " off_cpu queue\n"
63 msg = msg % (record.id) 64 msg = msg % (record.id)
64 sys.stderr.write(msg) 65 sys.stderr.write(msg)
65 exit() 66 exit()
66 job = eligible[pos] 67 job = off_cpu[pos]
67 del eligible[pos] 68 del off_cpu[pos]
68 on_cpu.append(job) 69 on_cpu.append(job)
69 70
70 # Mark a Job as completed. 71 # Mark a Job as completed.
@@ -75,8 +76,8 @@ def gedf_test(stream):
75 if pos is not None: 76 if pos is not None:
76 on_cpu[pos].is_complete = True 77 on_cpu[pos].is_complete = True
77 else: 78 else:
78 pos = _find_job(record,eligible) 79 pos = _find_job(record,off_cpu)
79 del eligible[pos] 80 del off_cpu[pos]
80 81
81 # A job is switched away from a CPU. If it has 82 # A job is switched away from a CPU. If it has
82 # been marked as complete, remove it from the model. 83 # been marked as complete, remove it from the model.
@@ -91,7 +92,7 @@ def gedf_test(stream):
91 job = on_cpu[pos] 92 job = on_cpu[pos]
92 del on_cpu[pos] 93 del on_cpu[pos]
93 if job.is_complete == False: 94 if job.is_complete == False:
94 eligible.append(job) 95 off_cpu.append(job)
95 96
96 # A job has been blocked. 97 # A job has been blocked.
97 elif record.type_name == 'block': 98 elif record.type_name == 'block':
@@ -99,16 +100,16 @@ def gedf_test(stream):
99 # What if the job is blocked AFTER being switched away? 100 # What if the job is blocked AFTER being switched away?
100 # This is a bug in some versions of LITMUS. 101 # This is a bug in some versions of LITMUS.
101 if pos is None: 102 if pos is None:
102 pos = _find_job(record,eligible) 103 pos = _find_job(record,off_cpu)
103 job = eligible[pos] 104 job = off_cpu[pos]
104 else: 105 else:
105 job = on_cpu[pos] 106 job = on_cpu[pos]
106 job.is_blocked = True 107 job.is_blocked = True
107 108
108 # A job is resumed 109 # A job is resumed
109 elif record.type_name == 'resume': 110 elif record.type_name == 'resume':
110 pos = _find_job(record,eligible) 111 pos = _find_job(record,off_cpu)
111 job = eligible[pos] 112 job = off_cpu[pos]
112 job.is_blocked = False 113 job.is_blocked = False
113 114
114 last_time = record.when 115 last_time = record.when
@@ -136,11 +137,11 @@ class Job(object):
136# G-EDF errors: the start or end of an inversion 137# G-EDF errors: the start or end of an inversion
137class Error(object): 138class Error(object):
138 id = 0 139 id = 0
139 def __init__(self, job, eligible, on_cpu,first_event_this_timestamp): 140 def __init__(self, job, off_cpu, on_cpu,first_event_this_timestamp):
140 Error.id += 1 141 Error.id += 1
141 self.id = Error.id 142 self.id = Error.id
142 self.job = copy.copy(job) 143 self.job = copy.copy(job)
143 self.eligible = copy.copy(eligible) 144 self.off_cpu = copy.copy(off_cpu)
144 self.on_cpu = copy.copy(on_cpu) 145 self.on_cpu = copy.copy(on_cpu)
145 self.record_type = 'error' 146 self.record_type = 'error'
146 self.triggering_event_id = first_event_this_timestamp 147 self.triggering_event_id = first_event_this_timestamp
@@ -161,7 +162,7 @@ def _find_job(record,list):
161 return None 162 return None
162 163
163# Return records for any inversion_starts and inversion_ends 164# Return records for any inversion_starts and inversion_ends
164def _gedf_check(eligible,on_cpu,when,m,first_event_this_timestamp): 165def _gedf_check(off_cpu,on_cpu,when,m,first_event_this_timestamp):
165 166
166 # List of error records to be returned 167 # List of error records to be returned
167 errors = [] 168 errors = []
@@ -172,7 +173,7 @@ def _gedf_check(eligible,on_cpu,when,m,first_event_this_timestamp):
172 for x in on_cpu: 173 for x in on_cpu:
173 if x.is_complete is not True and x.is_blocked is not True: 174 if x.is_complete is not True and x.is_blocked is not True:
174 all.append(x) 175 all.append(x)
175 for x in eligible: 176 for x in off_cpu:
176 if x.is_blocked is not True: 177 if x.is_blocked is not True:
177 all.append(x) 178 all.append(x)
178 179
@@ -190,14 +191,14 @@ def _gedf_check(eligible,on_cpu,when,m,first_event_this_timestamp):
190 # It's not running and an inversion_start has not been recorded 191 # It's not running and an inversion_start has not been recorded
191 if job not in on_cpu and job.inversion_start is None: 192 if job not in on_cpu and job.inversion_start is None:
192 job.inversion_start = when 193 job.inversion_start = when
193 errors.append(Error(job, eligible, on_cpu, 194 errors.append(Error(job, off_cpu, on_cpu,
194 first_event_this_timestamp)) 195 first_event_this_timestamp))
195 196
196 # It is running and an inversion_start exists (i.e. it it still 197 # It is running and an inversion_start exists (i.e. it it still
197 # marked as being inverted) 198 # marked as being inverted)
198 elif job in on_cpu and job.inversion_start is not None: 199 elif job in on_cpu and job.inversion_start is not None:
199 job.inversion_end = when 200 job.inversion_end = when
200 errors.append(Error(job, eligible, on_cpu, 201 errors.append(Error(job, off_cpu, on_cpu,
201 first_event_this_timestamp)) 202 first_event_this_timestamp))
202 job.inversion_start = None 203 job.inversion_start = None
203 job.inversion_end = None 204 job.inversion_end = None
@@ -208,17 +209,17 @@ def _gedf_check(eligible,on_cpu,when,m,first_event_this_timestamp):
208 job = all[x] 209 job = all[x]
209 if job not in on_cpu and job.inversion_start is not None: 210 if job not in on_cpu and job.inversion_start is not None:
210 job.inversion_end = when 211 job.inversion_end = when
211 errors.append(Error(job, eligible, on_cpu, 212 errors.append(Error(job, off_cpu, on_cpu,
212 first_event_this_timestamp)) 213 first_event_this_timestamp))
213 job.inversion_start = None 214 job.inversion_start = None
214 job.inversion_end = None 215 job.inversion_end = None
215 216
216 # Look for priority inversions among blocked tasks and end them 217 # Look for priority inversions among blocked tasks and end them
217 all = filter(lambda x:x.is_blocked and x.inversion_start is not None, 218 all = filter(lambda x:x.is_blocked and x.inversion_start is not None,
218 on_cpu + eligible) 219 on_cpu + off_cpu)
219 for job in all: 220 for job in all:
220 job.inversion_end = when 221 job.inversion_end = when
221 errors.append(Error(job, eligible, on_cpu, 222 errors.append(Error(job, off_cpu, on_cpu,
222 first_event_this_timestamp)) 223 first_event_this_timestamp))
223 job.inversion_start = None 224 job.inversion_start = None
224 job.inversion_end = None 225 job.inversion_end = None