X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsim%2Feventq.hh;h=895f69424af2c31c0178799a05d10daf645fee93;hb=abd33d6fd26bb69d3bf53ceb6c2dc8f90d893e34;hp=6d68b4e3aa6f18d3a24e943cb6cf55fc1b18ca80;hpb=e34924b50fd3362dc51a67c51c6d7f2b2015cf30;p=gem5.git diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index 6d68b4e3a..895f69424 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -160,6 +161,9 @@ class EventBase /// (such as writebacks). static const Priority CPU_Tick_Pri = 50; + /// If we want to exit a thread in a CPU, it comes after CPU_Tick_Pri + static const Priority CPU_Exit_Pri = 64; + /// Statistics events (dump, reset, etc.) come after /// everything else, but before exit. static const Priority Stat_Event_Pri = 90; @@ -542,28 +546,36 @@ class EventQueue * example, be useful when performing IO across thread event * queues when timing is not crucial (e.g., during fast * forwarding). + * + * ScopedMigration does nothing if both eqs are the same */ class ScopedMigration { public: - ScopedMigration(EventQueue *_new_eq) - : new_eq(*_new_eq), old_eq(*curEventQueue()) + ScopedMigration(EventQueue *_new_eq, bool _doMigrate = true) + :new_eq(*_new_eq), old_eq(*curEventQueue()), + doMigrate((&new_eq != &old_eq)&&_doMigrate) { - old_eq.unlock(); - new_eq.lock(); - curEventQueue(&new_eq); + if (doMigrate){ + old_eq.unlock(); + new_eq.lock(); + curEventQueue(&new_eq); + } } ~ScopedMigration() { - new_eq.unlock(); - old_eq.lock(); - curEventQueue(&old_eq); + if (doMigrate){ + new_eq.unlock(); + old_eq.lock(); + curEventQueue(&old_eq); + } } private: EventQueue &new_eq; EventQueue &old_eq; + bool doMigrate; }; /** @@ -702,7 +714,11 @@ class EventQueue */ void checkpointReschedule(Event *event); - virtual ~EventQueue() { } + virtual ~EventQueue() + { + while (!empty()) + deschedule(getHead()); + } }; void dumpMainQueue();