Andreas Sandberg has uploaded this change for review. ( https://gem5-review.googlesource.com/5730

Change subject: sim: ScopedMigration does nothing if both eqs are the same
......................................................................

sim: ScopedMigration does nothing if both eqs are the same

Added a check to avoid unlocking/locking the same event queue. Also,
added an optional parameter to enable the migration to be skipped. This
can be useful to disable the synchronization for certain runtime
conditions.

Change-Id: I4b03b3ffff4f9503153cd41dd8aa78705bf16cc4
Reviewed-by: Andreas Sandberg <[email protected]>
---
M src/sim/eventq.hh
1 file changed, 16 insertions(+), 8 deletions(-)



diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 6d68b4e..0a0405f 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -542,28 +542,36 @@
      * 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;
     };

     /**

--
To view, visit https://gem5-review.googlesource.com/5730
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b03b3ffff4f9503153cd41dd8aa78705bf16cc4
Gerrit-Change-Number: 5730
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to