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 |
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 |
103 Priority _priority; //!< event priority |
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. |
189 |
190 /// Minimum priority 191 static const Priority Minimum_Pri = SCHAR_MIN; |
192 |
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; |
197 |
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; |
202 |
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; |
208 |
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 |
214 /// Default is zero for historical reasons. 215 static const Priority Default_Pri = 0; |
216 |
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; |
221 |
222 /// CPU ticks must come after other associated CPU events 223 /// (such as writebacks). 224 static const Priority CPU_Tick_Pri = 50; |
225 |
226 /// Statistics events (dump, reset, etc.) come after 227 /// everything else, but before exit. 228 static const Priority Stat_Event_Pri = 90; |
229 |
230 /// Progress events come at the end. 231 static const Priority Progress_Event_Pri = 95; |
232 |
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; |
236 |
237 /// Maximum priority 238 static const Priority Maximum_Pri = SCHAR_MAX; 239 |
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 |
298 Priority priority() const { return _priority; } |
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 --- |