Go to the documentation of this file.
36 #include <unordered_map>
42 #include "debug/Checkpoint.hh"
85 return csprintf(
"Event_%s", instanceString());
95 if (!curr || *
event < *curr) {
114 if (!head || *
event <= *head) {
123 while (curr && *curr < *
event) {
151 while (
event != next) {
153 panic(
"event not found!");
168 panic(
"event not found!");
170 assert(
event->queue ==
this);
174 if (*head == *
event) {
182 while (curr && *curr < *
event) {
187 if (!curr || *curr != *
event)
188 panic(
"event not found!");
199 std::lock_guard<EventQueue>
lock(*
this);
217 if (!
event->squashed()) {
219 setCurTick(
event->when());
221 event->trace(
"executed");
223 if (
event->isExitEvent()) {
242 short _flags = flags;
249 assert(!scheduled());
263 assert(initialized());
265 flags.set(Initialized);
270 if (flags.isSet(Scheduled) && !flags.isSet(Squashed)) {
271 flags.clear(Squashed | Scheduled);
273 DPRINTF(Checkpoint,
"Event '%s' need to be scheduled @%d\n",
290 cprintf(
"============================================================\n");
292 cprintf(
"------------------------------------------------------------\n");
297 Event *nextBin = head;
299 Event *nextInBin = nextBin;
309 cprintf(
"============================================================\n");
315 std::unordered_map<long, bool> map;
320 Event *nextBin = head;
322 Event *nextInBin = nextBin;
324 if (nextInBin->
when() < time) {
325 cprintf(
"time goes backwards!");
328 }
else if (nextInBin->
when() == time &&
335 if (map[
reinterpret_cast<long>(nextInBin)]) {
340 map[
reinterpret_cast<long>(nextInBin)] =
true;
342 time = nextInBin->
when();
390 description(), instanceString(), action, when());
399 return csprintf(
"%#x", (uintptr_t)
this);
407 cprintf(
"Flags: %#x\n", flags);
409 cprintf(
"Created: %d\n", whenCreated);
413 cprintf(
"Scheduled at %d\n", whenScheduled);
415 cprintf(
"Scheduled for %d, priority %d\n", when(), _priority);
422 : objName(
n), head(NULL), _curTick(0)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
std::mutex async_queue_mutex
Mutex to protect async queue.
static Event * insertBefore(Event *event, Event *curr)
EventQueue * getEventQueue(uint32_t index)
Function for returning eventq queue for the provided index.
#define UNSERIALIZE_SCALAR(scalar)
void checkpointReschedule(Event *event)
Reschedule an event after a checkpoint.
static const FlagsType Scheduled
Event * replaceHead(Event *s)
function for replacing the head of the event queue, so that a different set of events can run without...
std::list< Event * > async_queue
List of events added by other threads to this event queue.
bool inParallelMode
Current mode of execution: parallel / serial.
uint64_t Tick
Tick count type.
void dump() const
Dump the current event data.
void dump() const
This is a debugging function which will print everything on the event queue.
virtual const char * description() const
Return a C string describing the event.
static const FlagsType IsMainQueue
Tick when() const
Get the time that the event is scheduled.
static const FlagsType Managed
int64_t Counter
Statistics counter type.
vector< EventQueue * > mainEventQueue
Array for main event queues.
void cprintf(const char *format, const Args &...args)
void handleAsyncInsertions()
Function for moving events from the async_queue to the main queue.
virtual void trace(const char *action)
This function isn't really useful if TRACING_ON is not defined.
EventQueue * curEventQueue()
void asyncInsert(Event *event)
Function for adding events to the async queue.
const std::string instanceString() const
Return the instance number as a string.
Priority priority() const
Get the event priority.
void insert(Event *event)
Insert / remove event from the queue.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
#define DPRINTF_UNCONDITIONAL(x,...)
Overload hash function for BasicBlockRange type.
void remove(Event *event)
static Event * removeItem(Event *event, Event *last)
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
std::ostream CheckpointOut
static const FlagsType Squashed
Queue of events sorted in time order.
EventQueue(const EventQueue &)
uint32_t numMainEventQueues
Current number of allocated main event queues.
virtual const std::string name() const
std::string csprintf(const char *format, const Args &...args)
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
static Counter instanceCounter
Global counter to generate unique IDs for Event instances.
void serialize(CheckpointOut &cp) const override
Serialize an object.
#define panic(...)
This implements a cprintf based panic() function.
Tick curTick()
The current simulated tick.
Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17