2 * Copyright (c) 2000-2003 The Regents of The University of Michigan
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;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include "cpu/full_cpu/smt.hh"
37 #include "base/misc.hh"
39 #include "sim/eventq.hh"
40 #include "base/trace.hh"
41 #include "sim/universe.hh"
48 // Events on this queue are processed at the *beginning* of each
49 // cycle, before the pipeline simulation is performed.
51 EventQueue
mainEventQueue("MainEventQueue");
54 EventQueue::insert(Event
*event
)
56 if (head
== NULL
|| event
->when() < head
->when() ||
57 (event
->when() == head
->when() &&
58 event
->priority() <= head
->priority())) {
63 Event
*curr
= head
->next
;
66 if (event
->when() <= curr
->when() &&
67 (event
->when() < curr
->when() ||
68 event
->priority() <= curr
->priority()))
81 EventQueue::remove(Event
*event
)
92 Event
*curr
= head
->next
;
93 while (curr
&& curr
!= event
) {
99 prev
->next
= curr
->next
;
103 EventQueue::serviceOne()
106 event
->clearFlags(Event::Scheduled
);
110 if (!event
->squashed())
113 event
->clearFlags(Event::Squashed
);
115 if (event
->getFlags(Event::AutoDelete
) && !event
->scheduled())
121 Event::serialize(std::ostream
&os
)
123 SERIALIZE_SCALAR(_when
);
124 SERIALIZE_SCALAR(_priority
);
125 SERIALIZE_ENUM(_flags
);
130 Event::unserialize(Checkpoint
*cp
, const string
§ion
)
135 UNSERIALIZE_SCALAR(_when
);
136 UNSERIALIZE_SCALAR(_priority
);
138 // need to see if original event was in a scheduled, unsquashed
139 // state, but don't want to restore those flags in the current
140 // object itself (since they aren't immediately true)
141 UNSERIALIZE_ENUM(_flags
);
142 bool wasScheduled
= (_flags
& Scheduled
) && !(_flags
& Squashed
);
143 _flags
&= ~(Squashed
| Scheduled
);
146 DPRINTF(Config
, "rescheduling at %d\n", _when
);
152 EventQueue::serialize(ostream
&os
)
154 std::list
<Event
*> eventPtrs
;
159 if (event
->getFlags(Event::AutoSerialize
)) {
160 eventPtrs
.push_back(event
);
161 paramOut(os
, csprintf("event%d", numEvents
++), event
->name());
166 SERIALIZE_SCALAR(numEvents
);
168 for (std::list
<Event
*>::iterator it
=eventPtrs
.begin();
169 it
!= eventPtrs
.end(); ++it
) {
171 (*it
)->serialize(os
);
176 EventQueue::unserialize(Checkpoint
*cp
, const std::string
§ion
)
179 UNSERIALIZE_SCALAR(numEvents
);
181 std::string eventName
;
182 for (int i
= 0; i
< numEvents
; i
++) {
183 // get the pointer value associated with the event
184 paramIn(cp
, section
, csprintf("event%d", i
), eventName
);
186 // create the event based on its pointer value
187 Serializable::create(cp
, eventName
);
194 cprintf("============================================================\n");
195 cprintf("EventQueue Dump (cycle %d)\n", curTick
);
196 cprintf("------------------------------------------------------------\n");
199 cprintf("<No Events>\n");
208 cprintf("============================================================\n");
215 mainEventQueue
.dump();
227 Event::trace(const char *action
)
229 // This DPRINTF is unconditional because calls to this function
230 // are protected by an 'if (DTRACE(Event))' in the inlined Event
233 // This is just a default implementation for derived classes where
234 // it's not worth doing anything special. If you want to put a
235 // more informative message in the trace, override this method on
236 // the particular subclass where you have the information that
237 // needs to be printed.
238 DPRINTFN("%s event %s @ %d\n", description(), action
, when());
245 cprintf("Event (%s)\n", description());
246 cprintf("Flags: %#x\n", _flags
);
248 cprintf("Created: %d\n", when_created
);
252 cprintf("Scheduled at %d\n", when_scheduled
);
254 cprintf("Scheduled for %d, priority %d\n", when(), _priority
);
257 cprintf("Not Scheduled\n");