35 #ifndef __SIM_EVENTQ_HH__
36 #define __SIM_EVENTQ_HH__
51 #include "debug/Event.hh"
59 class BaseGlobalEvent;
100 typedef ::gem5::Flags<FlagsType>
Flags;
352 virtual void trace(
const char *action);
434 virtual const std::string
name()
const;
532 return l.when() <
r.when() ||
533 (
l.when() ==
r.when() &&
l.priority() <
r.priority());
542 return l.when() >
r.when() ||
543 (
l.when() ==
r.when() &&
l.priority() >
r.priority());
552 return l.when() <
r.when() ||
553 (
l.when() ==
r.when() &&
l.priority() <=
r.priority());
562 return l.when() >
r.when() ||
563 (
l.when() ==
r.when() &&
l.priority() >=
r.priority());
572 return l.when() ==
r.when() &&
l.priority() ==
r.priority();
581 return l.when() !=
r.when() ||
l.priority() !=
r.priority();
767 assert(!
event->scheduled());
768 assert(
event->initialized());
770 event->setWhen(when,
this);
788 event->trace(
"scheduled");
799 assert(
event->scheduled());
800 assert(
event->initialized());
809 event->trace(
"descheduled");
824 assert(always ||
event->scheduled());
825 assert(
event->initialized());
828 if (
event->scheduled()) {
834 event->setWhen(when,
this);
840 event->trace(
"rescheduled");
1083 template <
class T,
void (T::* F)()>
1109 return object->name() +
".wrapped_event";
1129 const std::string &
name,
1149 return _name +
".wrapped_function_event";
1163 #define SERIALIZE_EVENT(event) event.serializeSection(cp, #event);
1170 #define UNSERIALIZE_EVENT(event) \
1172 event.unserializeSection(cp, #event); \
1173 eventQueue()->checkpointReschedule(&event); \
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Common base class for GlobalEvent and GlobalSyncEvent.
Common base class for Event and GlobalEvent, so they can share flag and priority definitions and acce...
static const FlagsType Squashed
::gem5::Flags< FlagsType > Flags
static const FlagsType IsMainQueue
static const FlagsType Initialized
static const FlagsType Managed
static const FlagsType Scheduled
static const FlagsType AutoDelete
static const FlagsType PublicWrite
static const FlagsType PublicRead
static const FlagsType InitMask
static const FlagsType Reserved0
This used to be AutoSerialize.
static const FlagsType IsExitEvent
std::function< void(void)> callback
void setCurTick(Tick newVal)
EventQueue * eventq
A pointer to this object's event queue.
ScopedRelease(EventQueue *_eq)
Temporarily release the event queue service lock.
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.
UncontendedMutex service_mutex
Lock protecting event handling.
const std::string name() const
const char * description() const
Return a C string describing the event.
EventWrapper(T *obj, bool del=false, Priority p=Default_Pri)
EventWrapper(T &obj, bool del=false, Priority p=Default_Pri)
Priority _priority
event priority
static Event * removeItem(Event *event, Event *last)
virtual void acquireImpl()
bool isFlagSet(Flags _flags) const
void setWhen(Tick when, EventQueue *q)
virtual void releaseImpl()
EventQueue * queue
queue to which this event belongs (though it may or may not be scheduled on this queue yet)
void acquire()
Memory management hooks for events that have the Managed flag set.
static Event * insertBefore(Event *event, Event *curr)
void release()
Managed event removed from the event queue.
void setFlags(Flags _flags)
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.
Event(Priority p=Default_Pri, Flags f=0)
virtual BaseGlobalEvent * globalEvent()
If this is part of a GlobalEvent, return the pointer to the Global Event.
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 clearFlags(Flags _flags)
Basic support for object serialization.
EventManager(EventQueue *eq)
const char * description() const
Return a C string describing the event.
void dump() const
This is a debugging function which will print everything on the event queue.
const std::string name() const
ScopedMigration(EventQueue *_new_eq, bool _doMigrate=true)
Temporarily migrate execution to a different event queue.
void reschedule(Event *event, Tick when, bool always=false)
Reschedule the specified event.
static const Priority Delayed_Writeback_Pri
For some reason "delayed" inter-cluster writebacks are scheduled before regular writebacks (which hav...
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
static const Priority Debug_Break_Pri
Breakpoints should happen before anything else (except enabling trace output), so we don't miss any a...
virtual void trace(const char *action)
This function isn't really useful if TRACING_ON is not defined.
void schedule(Event *event, Tick when)
void deschedule(Event *event)
Deschedule the specified event.
void deschedule(Event &event)
static const Priority Maximum_Pri
Maximum priority.
EventFunctionWrapper(const std::function< void(void)> &callback, const std::string &name, bool del=false, Priority p=Default_Pri)
This function wraps a function into an event, to be executed later.
bool isAutoDelete() const
The function returns true if the object is automatically deleted after the event is processed.
void name(const std::string &st)
void wakeupEventQueue(Tick when=(Tick) -1)
This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues ...
void serviceEvents(Tick when)
process all events up to the given timestamp.
void deschedule(Event *event)
EventQueue * eventQueue() const
virtual const std::string name() const
virtual const std::string name() const
bool scheduled() const
Determine if the current event is scheduled.
void reschedule(Event *event, Tick when, bool always=false)
void squash()
Squash the current event.
Tick getCurTick() const
While curTick() is useful for any object assigned to this event queue, if an object that is assigned ...
static const Priority CPU_Switch_Pri
CPU switches schedule the new CPU's tick event for the same cycle (after unscheduling the old CPU's t...
void schedule(Event &event, Tick when)
EventManager(EventManager &em)
Event manger manages events in the event queue.
void dump() const
Dump the current event data.
Priority priority() const
Get the event priority.
bool isManaged() const
Check whether this event will auto-delete.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
EventManager(EventManager *em)
static const Priority Progress_Event_Pri
Progress events come at the end.
void reschedule(Event &event, Tick when, bool always=false)
bool empty() const
Returns true if no events are queued.
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
virtual void wakeup(Tick when=(Tick) -1)
Function to signal that the event loop should be woken up because an event has been scheduled by an a...
virtual const char * description() const
Return a C string describing the event.
Tick when() const
Get the time that the event is scheduled.
static const Priority Default_Pri
Default is zero for historical reasons.
static const Priority Debug_Enable_Pri
If we enable tracing on a particular cycle, do that as the very first thing so we don't miss any of t...
static const Priority Serialize_Pri
Serailization needs to occur before tick events also, so that a serialize/unserialize is identical to...
static const Priority CPU_Exit_Pri
If we want to exit a thread in a CPU, it comes after CPU_Tick_Pri.
static const Priority Stat_Event_Pri
Statistics events (dump, reset, etc.) come after everything else, but before exit.
bool squashed() const
Check whether the event is squashed.
static const Priority Minimum_Pri
Event priorities, to provide tie-breakers for events scheduled at the same cycle.
bool isExitEvent() const
See if this is a SimExitEvent (without resorting to RTTI)
static const Priority DVFS_Update_Pri
DVFS update event leads to stats dump therefore given a lower priority to ensure all relevant states ...
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.
bool noneSet(Type mask) const
Verifies whether no bits matching the given mask are set.
__thread Tick * _curTickPtr
double Counter
All counters are of 64-bit values.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
bool operator>(const Time &l, const Time &r)
static bool operator==(const PCStateBase &a, const PCStateBase &b)
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
uint64_t Tick
Tick count type.
EventQueue * curEventQueue()
uint32_t numMainEventQueues
Current number of allocated main event queues.
static bool operator!=(const PCStateBase &a, const PCStateBase &b)
bool operator>=(const Time &l, const Time &r)
bool operator<(const Time &l, const Time &r)
bool operator<=(const Time &l, const Time &r)
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.