eventq.hh (7005:3d5c4acb6015) eventq.hh (7058:5c7416199efd)
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 66 unchanged lines hidden (view full) ---

75 static const FlagsType AutoDelete = 0x0004;
76 static const FlagsType AutoSerialize = 0x0008;
77 static const FlagsType IsExitEvent = 0x0010;
78 static const FlagsType IsMainQueue = 0x0020;
79#ifdef EVENTQ_DEBUG
80 static const FlagsType Initialized = 0xf000;
81#endif
82
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 66 unchanged lines hidden (view full) ---

75 static const FlagsType AutoDelete = 0x0004;
76 static const FlagsType AutoSerialize = 0x0008;
77 static const FlagsType IsExitEvent = 0x0010;
78 static const FlagsType IsMainQueue = 0x0020;
79#ifdef EVENTQ_DEBUG
80 static const FlagsType Initialized = 0xf000;
81#endif
82
83 public:
84 typedef int8_t Priority;
85
83 private:
84 // The event queue is now a linked list of linked lists. The
85 // 'nextBin' pointer is to find the bin, where a bin is defined as
86 // when+priority. All events in the same bin will be stored in a
87 // second linked list (a stack) maintained by the 'nextInBin'
88 // pointer. The list will be accessed in LIFO order. The end
89 // result is that the insert/removal in 'nextBin' is
90 // linear/constant, and the lookup/removal in 'nextInBin' is
91 // constant/constant. Hopefully this is a significant improvement
92 // over the current fully linear insertion.
93 Event *nextBin;
94 Event *nextInBin;
95
96 static Event *insertBefore(Event *event, Event *curr);
97 static Event *removeItem(Event *event, Event *last);
98
99 Tick _when; //!< timestamp when event should be processed
86 private:
87 // The event queue is now a linked list of linked lists. The
88 // 'nextBin' pointer is to find the bin, where a bin is defined as
89 // when+priority. All events in the same bin will be stored in a
90 // second linked list (a stack) maintained by the 'nextInBin'
91 // pointer. The list will be accessed in LIFO order. The end
92 // result is that the insert/removal in 'nextBin' is
93 // linear/constant, and the lookup/removal in 'nextInBin' is
94 // constant/constant. Hopefully this is a significant improvement
95 // over the current fully linear insertion.
96 Event *nextBin;
97 Event *nextInBin;
98
99 static Event *insertBefore(Event *event, Event *curr);
100 static Event *removeItem(Event *event, Event *last);
101
102 Tick _when; //!< timestamp when event should be processed
100 short _priority; //!< event priority
103 Priority _priority; //!< event priority
101 Flags flags;
102
103#ifndef NDEBUG
104 /// Global counter to generate unique IDs for Event instances
105 static Counter instanceCounter;
106
107 /// This event's unique ID. We can also use pointer values for
108 /// this but they're not consistent across runs making debugging

--- 69 unchanged lines hidden (view full) ---

178 // This function isn't really useful if TRACING_ON is not defined
179 virtual void trace(const char *action); //!< trace event activity
180
181 public:
182 /// Event priorities, to provide tie-breakers for events scheduled
183 /// at the same cycle. Most events are scheduled at the default
184 /// priority; these values are used to control events that need to
185 /// be ordered within a cycle.
104 Flags flags;
105
106#ifndef NDEBUG
107 /// Global counter to generate unique IDs for Event instances
108 static Counter instanceCounter;
109
110 /// This event's unique ID. We can also use pointer values for
111 /// this but they're not consistent across runs making debugging

--- 69 unchanged lines hidden (view full) ---

181 // This function isn't really useful if TRACING_ON is not defined
182 virtual void trace(const char *action); //!< trace event activity
183
184 public:
185 /// Event priorities, to provide tie-breakers for events scheduled
186 /// at the same cycle. Most events are scheduled at the default
187 /// priority; these values are used to control events that need to
188 /// be ordered within a cycle.
186 enum Priority {
187 /// Minimum priority
188 Minimum_Pri = SHRT_MIN,
189
189
190 /// If we enable tracing on a particular cycle, do that as the
191 /// very first thing so we don't miss any of the events on
192 /// that cycle (even if we enter the debugger).
193 Trace_Enable_Pri = -101,
190 /// Minimum priority
191 static const Priority Minimum_Pri = SCHAR_MIN;
194
192
195 /// Breakpoints should happen before anything else (except
196 /// enabling trace output), so we don't miss any action when
197 /// debugging.
198 Debug_Break_Pri = -100,
193 /// If we enable tracing on a particular cycle, do that as the
194 /// very first thing so we don't miss any of the events on
195 /// that cycle (even if we enter the debugger).
196 static const Priority Trace_Enable_Pri = -101;
199
197
200 /// CPU switches schedule the new CPU's tick event for the
201 /// same cycle (after unscheduling the old CPU's tick event).
202 /// The switch needs to come before any tick events to make
203 /// sure we don't tick both CPUs in the same cycle.
204 CPU_Switch_Pri = -31,
198 /// Breakpoints should happen before anything else (except
199 /// enabling trace output), so we don't miss any action when
200 /// debugging.
201 static const Priority Debug_Break_Pri = -100;
205
202
206 /// For some reason "delayed" inter-cluster writebacks are
207 /// scheduled before regular writebacks (which have default
208 /// priority). Steve?
209 Delayed_Writeback_Pri = -1,
203 /// CPU switches schedule the new CPU's tick event for the
204 /// same cycle (after unscheduling the old CPU's tick event).
205 /// The switch needs to come before any tick events to make
206 /// sure we don't tick both CPUs in the same cycle.
207 static const Priority CPU_Switch_Pri = -31;
210
208
211 /// Default is zero for historical reasons.
212 Default_Pri = 0,
209 /// For some reason "delayed" inter-cluster writebacks are
210 /// scheduled before regular writebacks (which have default
211 /// priority). Steve?
212 static const Priority Delayed_Writeback_Pri = -1;
213
213
214 /// Serailization needs to occur before tick events also, so
215 /// that a serialize/unserialize is identical to an on-line
216 /// CPU switch.
217 Serialize_Pri = 32,
214 /// Default is zero for historical reasons.
215 static const Priority Default_Pri = 0;
218
216
219 /// CPU ticks must come after other associated CPU events
220 /// (such as writebacks).
221 CPU_Tick_Pri = 50,
217 /// Serailization needs to occur before tick events also, so
218 /// that a serialize/unserialize is identical to an on-line
219 /// CPU switch.
220 static const Priority Serialize_Pri = 32;
222
221
223 /// Statistics events (dump, reset, etc.) come after
224 /// everything else, but before exit.
225 Stat_Event_Pri = 90,
222 /// CPU ticks must come after other associated CPU events
223 /// (such as writebacks).
224 static const Priority CPU_Tick_Pri = 50;
226
225
227 /// Progress events come at the end.
228 Progress_Event_Pri = 95,
226 /// Statistics events (dump, reset, etc.) come after
227 /// everything else, but before exit.
228 static const Priority Stat_Event_Pri = 90;
229
229
230 /// If we want to exit on this cycle, it's the very last thing
231 /// we do.
232 Sim_Exit_Pri = 100,
230 /// Progress events come at the end.
231 static const Priority Progress_Event_Pri = 95;
233
232
234 /// Maximum priority
235 Maximum_Pri = SHRT_MAX
236 };
233 /// If we want to exit on this cycle, it's the very last thing
234 /// we do.
235 static const Priority Sim_Exit_Pri = 100;
237
236
237 /// Maximum priority
238 static const Priority Maximum_Pri = SCHAR_MAX;
239
238 /*
239 * Event constructor
240 * @param queue that the event gets scheduled on
241 */
242 Event(Priority p = Default_Pri)
243 : nextBin(NULL), nextInBin(NULL), _priority(p)
244 {
245#ifndef NDEBUG

--- 42 unchanged lines hidden (view full) ---

288
289 /// See if this is a SimExitEvent (without resorting to RTTI)
290 bool isExitEvent() const { return flags.isSet(IsExitEvent); }
291
292 /// Get the time that the event is scheduled
293 Tick when() const { return _when; }
294
295 /// Get the event priority
240 /*
241 * Event constructor
242 * @param queue that the event gets scheduled on
243 */
244 Event(Priority p = Default_Pri)
245 : nextBin(NULL), nextInBin(NULL), _priority(p)
246 {
247#ifndef NDEBUG

--- 42 unchanged lines hidden (view full) ---

290
291 /// See if this is a SimExitEvent (without resorting to RTTI)
292 bool isExitEvent() const { return flags.isSet(IsExitEvent); }
293
294 /// Get the time that the event is scheduled
295 Tick when() const { return _when; }
296
297 /// Get the event priority
296 int priority() const { return _priority; }
298 Priority priority() const { return _priority; }
297
298#ifndef SWIG
299 struct priority_compare
300 : public std::binary_function<Event *, Event *, bool>
301 {
302 bool
303 operator()(const Event *l, const Event *r) const
304 {

--- 282 unchanged lines hidden ---
299
300#ifndef SWIG
301 struct priority_compare
302 : public std::binary_function<Event *, Event *, bool>
303 {
304 bool
305 operator()(const Event *l, const Event *r) const
306 {

--- 282 unchanged lines hidden ---