2 * Copyright (c) 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"
45 const string
Event::defaultName("event");
50 // Events on this queue are processed at the *beginning* of each
51 // cycle, before the pipeline simulation is performed.
53 EventQueue
mainEventQueue("Main Event Queue");
56 EventQueue::insert(Event
*event
)
58 if (head
== NULL
|| event
->when() < head
->when() ||
59 (event
->when() == head
->when() &&
60 event
->priority() <= head
->priority())) {
65 Event
*curr
= head
->next
;
68 if (event
->when() <= curr
->when() &&
69 (event
->when() < curr
->when() ||
70 event
->priority() <= curr
->priority()))
83 EventQueue::remove(Event
*event
)
94 Event
*curr
= head
->next
;
95 while (curr
&& curr
!= event
) {
101 prev
->next
= curr
->next
;
105 EventQueue::serviceOne()
108 event
->clearFlags(Event::Scheduled
);
112 if (!event
->squashed())
115 event
->clearFlags(Event::Squashed
);
117 if (event
->getFlags(Event::AutoDelete
))
122 EventQueue::nameChildren()
129 ccprintf(stream
, "%s.event%d", name(), j
++);
130 event
->setName(stream
.str());
137 EventQueue::serialize()
143 objects
+= event
->name();
149 nameOut("Serialized");
150 paramOut("objects",objects
);
156 cprintf("============================================================\n");
157 cprintf("EventQueue Dump (cycle %d)\n", curTick
);
158 cprintf("------------------------------------------------------------\n");
161 cprintf("<No Events>\n");
170 cprintf("============================================================\n");
182 Event::trace(const char *action
)
184 // This DPRINTF is unconditional because calls to this function
185 // are protected by an 'if (DTRACE(Event))' in the inlined Event
188 // This is just a default implementation for derived classes where
189 // it's not worth doing anything special. If you want to put a
190 // more informative message in the trace, override this method on
191 // the particular subclass where you have the information that
192 // needs to be printed.
193 DPRINTFN("%s event %s @ %d\n", description(), action
, when());
201 cprintf(" Created: %d\n", when_created
);
205 cprintf(" Scheduled at %d\n", when_scheduled
);
207 cprintf(" Scheduled for %d\n", when());
210 cprintf(" Not Scheduled\n");