38 #ifndef __SIM_EVENTQ_HH__
39 #define __SIM_EVENTQ_HH__
51 #include "debug/Event.hh"
96 typedef ::Flags<FlagsType>
Flags;
284 virtual void trace(
const char *action);
357 virtual const std::string
name()
const;
771 template <
class T,
void (T::* F)()>
775 class DelayEvent :
public Event
782 :
Event(Default_Pri, AutoDelete), object(o)
784 void process() { (
object->*F)(); }
785 const char *
description()
const {
return "delay"; }
788 eventq->
schedule(
new DelayEvent(
object), when);
791 template <
class T,
void (T::* F)()>
817 return object->name() +
".wrapped_event";
823 #endif // __SIM_EVENTQ_HH__
EventQueue * eventq
A pointer to this object's event queue.
static const Priority Progress_Event_Pri
Progress events come at the end.
void serialize(CheckpointOut &cp) const override
Serialize an object.
uint32_t numMainEventQueues
Current number of allocated main event queues.
void DelayFunction(EventQueue *eventq, Tick when, T *object)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
virtual const std::string name() const
void deschedule(Event *event)
Deschedule the specified event.
virtual void acquireImpl()
static const FlagsType Managed
Counter instance
This event's unique ID.
::Flags< FlagsType > Flags
void asyncInsert(Event *event)
Function for adding events to the async queue.
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
bool isFlagSet(Flags _flags) const
void deschedule(Event *event)
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...
EventManager(EventManager *em)
void setCurTick(Tick newVal)
Tick _when
timestamp when event should be processed
void schedule(Event *event, Tick when)
Priority _priority
event priority
bool scheduled() const
Determine if the current event is scheduled.
static const Priority Debug_Break_Pri
Breakpoints should happen before anything else (except enabling trace output), so we don't miss any a...
static const FlagsType Initialized
const char * description() const
Return a C string describing the event.
static Event * insertBefore(Event *event, Event *curr)
static const FlagsType PublicRead
EventQueue * getEventQueue(uint32_t index)
Function for returning eventq queue for the provided index.
void insert(Event *event)
Insert / remove event from the queue.
void acquire()
Memory management hooks for events that have the Managed flag set.
void setWhen(Tick when, EventQueue *q)
void deschedule(Event &event)
bool operator>(const Event &l, const Event &r)
Priority priority() const
Get the event priority.
static const FlagsType AutoDelete
EventQueue(const EventQueue &)
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...
static const FlagsType Squashed
static const Priority Serialize_Pri
Serailization needs to occur before tick events also, so that a serialize/unserialize is identical to...
Tick curTick()
The current simulated tick.
Temporarily migrate execution to a different event queue.
void reschedule(Event *event, Tick when, bool always=false)
Reschedule the specified event.
bool isAutoDelete() const
Queue of events sorted in time order.
static const FlagsType Scheduled
const std::string name() const
Tick when() const
Get the time that the event is scheduled.
uint64_t Tick
Tick count type.
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
EventWrapper(T *obj, bool del=false, Priority p=Default_Pri)
virtual BaseGlobalEvent * globalEvent()
If this is part of a GlobalEvent, return the pointer to the Global Event.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
void reschedule(Event *event, Tick when, bool always=false)
EventQueue * curEventQueue()
bool squashed() const
Check whether the event is squashed.
bool operator>=(const Event &l, const Event &r)
void serviceEvents(Tick when)
void setFlags(Flags _flags)
Accessor for flags.
EventManager(EventQueue *eq)
static const FlagsType Reserved0
This used to be AutoSerialize.
void setCurTick(Tick newVal)
void squash()
Squash the current event.
bool operator<=(const Event &l, const Event &r)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
virtual void releaseImpl()
int64_t Counter
Statistics counter type.
EventQueue * eventQueue() const
bool operator!=(const Event &l, const Event &r)
std::mutex async_queue_mutex
Mutex to protect async queue.
std::mutex service_mutex
Lock protecting event handling.
Basic support for object serialization.
void wakeupEventQueue(Tick when=(Tick)-1)
bool inParallelMode
Current mode of execution: parallel / serial.
void checkpointReschedule(Event *event)
Reschedule an event after a checkpoint.
Event * replaceHead(Event *s)
function for replacing the head of the event queue, so that a different set of events can run without...
void clearFlags(Flags _flags)
void reschedule(Event &event, Tick when, bool always=false)
void handleAsyncInsertions()
Function for moving events from the async_queue to the main queue.
Event(Priority p=Default_Pri, Flags f=0)
std::ostream CheckpointOut
virtual const std::string name() const
static Event * removeItem(Event *event, Event *last)
bool isExitEvent() const
See if this is a SimExitEvent (without resorting to RTTI)
virtual void trace(const char *action)
trace event activity
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
ScopedRelease(EventQueue *_eq)
void dump() const
Dump the current event data.
void schedule(Event &event, Tick when)
static const Priority Default_Pri
Default is zero for historical reasons.
static const Priority Minimum_Pri
Event priorities, to provide tie-breakers for events scheduled at the same cycle. ...
__thread EventQueue * _curEventQueue
The current event queue for the running thread.
bool isManaged() const
Check whether this event will auto-delete.
Flags getFlags() const
Accessor for flags.
void release()
Managed event removed from the event queue.
static const FlagsType PublicWrite
void lock()
Provide an interface for locking/unlocking the event queue.
Common base class for GlobalEvent and GlobalSyncEvent.
static const Priority DVFS_Update_Pri
DVFS update event leads to stats dump therefore given a lower priority to ensure all relevant states ...
Common base class for Event and GlobalEvent, so they can share flag and priority definitions and acce...
ScopedMigration(EventQueue *_new_eq)
Temporarily release the event queue service lock.
virtual const char * description() const
Return a C string describing the event.
void name(const std::string &st)
static const Priority Delayed_Writeback_Pri
For some reason "delayed" inter-cluster writebacks are scheduled before regular writebacks (which hav...
std::list< Event * > async_queue
List of events added by other threads to this event queue.
EventWrapper(T &obj, bool del=false, Priority p=Default_Pri)
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
static Counter instanceCounter
Global counter to generate unique IDs for Event instances.
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 Stat_Event_Pri
Statistics events (dump, reset, etc.) come after everything else, but before exit.
static const FlagsType IsExitEvent
bool operator<(const Event &l, const Event &r)
EventQueue * queue
queue to which this event belongs (though it may or may not be scheduled on this queue yet) ...
EventManager(EventManager &em)
static const Priority Maximum_Pri
Maximum priority.
bool operator==(const Event &l, const Event &r)
static const FlagsType IsMainQueue
static const FlagsType InitMask