37 #include <unordered_map>
43 #include "debug/Checkpoint.hh"
96 if (!curr || *
event < *curr) {
124 while (curr && *curr < *
event) {
152 while (
event != next) {
154 panic(
"event not found!");
169 panic(
"event not found!");
171 assert(
event->queue ==
this);
183 while (curr && *curr < *
event) {
188 if (!curr || *curr != *
event)
189 panic(
"event not found!");
200 std::lock_guard<EventQueue>
lock(*
this);
218 if (!
event->squashed()) {
222 event->trace(
"executed");
224 if (
event->isExitEvent()) {
243 short _flags =
flags;
274 DPRINTF(Checkpoint,
"Event '%s' need to be scheduled @%d\n",
291 cprintf(
"============================================================\n");
293 cprintf(
"------------------------------------------------------------\n");
300 Event *nextInBin = nextBin;
310 cprintf(
"============================================================\n");
316 std::unordered_map<long, bool> map;
323 Event *nextInBin = nextBin;
325 if (nextInBin->
when() < time) {
326 cprintf(
"time goes backwards!");
329 }
else if (nextInBin->
when() == time &&
336 if (map[
reinterpret_cast<long>(nextInBin)]) {
341 map[
reinterpret_cast<long>(nextInBin)] =
true;
343 time = nextInBin->
when();
396 return csprintf(
"%#x", (uintptr_t)
this);
406 cprintf(
"Created: %d\n", whenCreated);
410 cprintf(
"Scheduled at %d\n", whenScheduled);
419 : objName(
n), head(NULL), _curTick(0)
static const FlagsType Squashed
static const FlagsType IsMainQueue
static const FlagsType Initialized
static const FlagsType Managed
static const FlagsType Scheduled
Queue of events sorted in time order.
EventQueue(const EventQueue &)
void handleAsyncInsertions()
Function for moving events from the async_queue to the main queue.
std::list< Event * > async_queue
List of events added by other threads to this event queue.
void setCurTick(Tick newVal)
void asyncInsert(Event *event)
Function for adding events to the async queue.
void lock()
Provide an interface for locking/unlocking the event queue.
void checkpointReschedule(Event *event)
Reschedule an event after a checkpoint.
friend void curEventQueue(EventQueue *)
void insert(Event *event)
Insert / remove event from the queue.
Event * replaceHead(Event *s)
function for replacing the head of the event queue, so that a different set of events can run without...
void remove(Event *event)
UncontendedMutex async_queue_mutex
Mutex to protect async queue.
Priority _priority
event priority
static Event * removeItem(Event *event, Event *last)
static Event * insertBefore(Event *event, Event *curr)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static Counter instanceCounter
Global counter to generate unique IDs for Event instances.
Counter instance
This event's unique ID.
Tick _when
timestamp when event should be processed
const std::string instanceString() const
Return the instance number as a string.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void dump() const
This is a debugging function which will print everything on the event queue.
virtual void trace(const char *action)
This function isn't really useful if TRACING_ON is not defined.
virtual const std::string name() const
bool scheduled() const
Determine if the current event is scheduled.
void dump() const
Dump the current event data.
Priority priority() const
Get the event priority.
bool empty() const
Returns true if no events are queued.
virtual const char * description() const
Return a C string describing the event.
Tick when() const
Get the time that the event is scheduled.
void set(Type mask)
Set all flag's bits matching the given mask.
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
void clear()
Clear all flag's bits.
#define panic(...)
This implements a cprintf based panic() function.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
void cprintf(const char *format, const Args &...args)
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
int64_t Counter
Statistics counter type.
uint64_t Tick
Tick count type.
uint32_t numMainEventQueues
Current number of allocated main event queues.
std::string csprintf(const char *format, const Args &...args)
bool inParallelMode
Current mode of execution: parallel / serial.
EventQueue * getEventQueue(uint32_t index)
Function for returning eventq queue for the provided index.
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)