summaryrefslogtreecommitdiffstats
path: root/unit_trace/viz/schedule.py
diff options
context:
space:
mode:
authorGary Bressler <garybressler@nc.rr.com>2010-04-06 12:45:04 -0400
committerGary Bressler <garybressler@nc.rr.com>2010-04-06 12:45:04 -0400
commitc7e3aaebdba7bf880534abd91a383b5543cf0be4 (patch)
tree048977efdaaa3d60e93c3d21ba29c46a0bfe71c3 /unit_trace/viz/schedule.py
parent7fdb4dbbbca577efbeec47cd1364eb319346a0cc (diff)
Making sure everything committed
Diffstat (limited to 'unit_trace/viz/schedule.py')
-rw-r--r--unit_trace/viz/schedule.py74
1 files changed, 48 insertions, 26 deletions
diff --git a/unit_trace/viz/schedule.py b/unit_trace/viz/schedule.py
index f134562..81269fa 100644
--- a/unit_trace/viz/schedule.py
+++ b/unit_trace/viz/schedule.py
@@ -5,7 +5,7 @@ the job releases and other events that have occurred for each task. This gives
5a high-level representation of a schedule that can be converted to, say, a 5a high-level representation of a schedule that can be converted to, say, a
6graphic.""" 6graphic."""
7 7
8from draw import * 8from graph import *
9import util 9import util
10 10
11import copy 11import copy
@@ -97,8 +97,16 @@ class TimeSlotArray(object):
97 97
98 self._put_event_in_slot(TimeSlotArray.TASK_LIST, task_no, dummy.__class__, slot, dummy) 98 self._put_event_in_slot(TimeSlotArray.TASK_LIST, task_no, dummy.__class__, slot, dummy)
99 self._put_event_in_slot(TimeSlotArray.CPU_LIST, cpu, dummy.__class__, slot, dummy) 99 self._put_event_in_slot(TimeSlotArray.CPU_LIST, cpu, dummy.__class__, slot, dummy)
100 100
101 def iter_over_period(self, start, end, start_no, end_no, list_type, event_types): 101 def get_events(self, slots, list_type, event_types):
102 for type in event_types:
103 for slot in slots:
104 for no in slots[slot]:
105 if slot in self.array[list_type][no][type]:
106 for event in self.array[list_type][no][type][slot]:
107 yield event
108
109 def get_slots(self, slots, start, end, start_no, end_no, list_type):
102 if self.array is None: 110 if self.array is None:
103 return # empty schedule 111 return # empty schedule
104 112
@@ -106,19 +114,17 @@ class TimeSlotArray(object):
106 raise ValueError('Litmus is not a time machine') 114 raise ValueError('Litmus is not a time machine')
107 if start_no > end_no: 115 if start_no > end_no:
108 raise ValueError('start no should be less than end no') 116 raise ValueError('start no should be less than end no')
109 117
110 start_slot = self.get_time_slot(start) 118 start_slot = self.get_time_slot(start)
111 end_slot = self.get_time_slot(end) + 2 119 end_slot = self.get_time_slot(end) + 1
112
113 start_no = max(0, start_no) 120 start_no = max(0, start_no)
114 end_no = min(self.list_sizes[list_type] - 1, end_no) 121 end_no = min(self.list_sizes[list_type] - 1, end_no)
115 122
116 for no in range(start_no, end_no + 1): 123 for slot in xrange(start_slot, end_slot + 1):
117 for type in event_types: 124 if slot not in slots:
118 for slot in range(start_slot, end_slot): 125 slots[slot] = {}
119 if slot in self.array[list_type][no][type]: 126 for no in xrange(start_no, end_no + 1):
120 for event in self.array[list_type][no][type][slot]: 127 slots[slot][no] = None
121 yield event
122 128
123class Schedule(object): 129class Schedule(object):
124 """The total schedule (task system), consisting of a certain number of 130 """The total schedule (task system), consisting of a certain number of
@@ -138,16 +144,26 @@ class Schedule(object):
138 def get_selected(self): 144 def get_selected(self):
139 return self.selected 145 return self.selected
140 146
141 def set_selected(self, new_selected): 147 def set_selected(self, selected):
142 for event in self.selected: 148 self.selected = selected
143 event.selected = False 149
144 for event in new_selected: 150 def add_selected(self, selected):
145 event.selected = True 151 for layer in selected:
146 self.selected = new_selected 152 if layer not in self.selected:
147 153 self.selected[layer] = {}
148 def get_selected(self): 154 for event in selected[layer]:
149 return copy.copy(self.selected) 155 if event not in self.selected:
156 self.selected[layer][event] = {}
157 for graph in selected[layer][event]:
158 self.selected[layer][event][graph] = selected[layer][event][graph]
150 159
160 def remove_selected(self, selected):
161 for layer in selected:
162 if layer in self.selected:
163 for event in selected[layer]:
164 if event in self.selected[layer]:
165 del self.selected[layer][event]
166
151 def set_time_params(self, time_per_maj=None): 167 def set_time_params(self, time_per_maj=None):
152 self.time_per_maj = time_per_maj 168 self.time_per_maj = time_per_maj
153 if self.time_per_maj is None: 169 if self.time_per_maj is None:
@@ -212,7 +228,13 @@ class Schedule(object):
212 228
213 def get_num_cpus(self): 229 def get_num_cpus(self):
214 return self.num_cpus 230 return self.num_cpus
215 231
232def deepcopy_selected(selected):
233 selected_copy = {}
234 for layer in selected:
235 selected_copy[layer] = copy.copy(selected[layer])
236 return selected_copy
237
216class Task(object): 238class Task(object):
217 """Represents a task, including the set of jobs that were run under 239 """Represents a task, including the set of jobs that were run under
218 this task.""" 240 this task."""
@@ -313,7 +335,6 @@ class Event(DummyEvent):
313 def __init__(self, time, cpu): 335 def __init__(self, time, cpu):
314 super(Event, self).__init__(time, cpu) 336 super(Event, self).__init__(time, cpu)
315 self.erroneous = False 337 self.erroneous = False
316 self.selected = False
317 338
318 def __str__(self): 339 def __str__(self):
319 return '[Event]' 340 return '[Event]'
@@ -332,7 +353,8 @@ class Event(DummyEvent):
332 353
333 def is_selected(self): 354 def is_selected(self):
334 """Returns whether the event has been selected by the user. (needed for rendering)""" 355 """Returns whether the event has been selected by the user. (needed for rendering)"""
335 return self.selected 356 selected = self.get_job().get_task().get_schedule().get_selected()
357 return self.get_layer() in selected and self in selected[self.get_layer()]
336 358
337 def scan(self, cur_cpu, switches): 359 def scan(self, cur_cpu, switches):
338 """Part of the procedure that walks through all the events and sets 360 """Part of the procedure that walks through all the events and sets
@@ -480,7 +502,7 @@ class SwitchAwayEvent(Event):
480 502
481 def __str__(self): 503 def __str__(self):
482 if self.corresp_start_event is None: 504 if self.corresp_start_event is None:
483 return 'Switch Away (w/o Switch To)' + self._common_str() + 'TIME=' \ 505 return 'Switch Away (w/o Switch To)' + self._common_str() + ', TIME=' \
484 + str(self.get_time()) 506 + str(self.get_time())
485 return str(self.corresp_start_event) 507 return str(self.corresp_start_event)
486 508
@@ -641,7 +663,7 @@ class InversionEndEvent(ErrorEvent):
641 663
642 if self.corresp_start_event is None: 664 if self.corresp_start_event is None:
643 self.erroneous = True 665 self.erroneous = True
644 print "inversion end was not matched by a corresponding inversion start" 666 #print "inversion end was not matched by a corresponding inversion start"
645 667
646 super(InversionEndEvent, self).scan(cur_cpu, switches) 668 super(InversionEndEvent, self).scan(cur_cpu, switches)
647 669