summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Muck <tiago.muck@arm.com>2017-09-08 12:24:42 -0500
committerAndreas Sandberg <andreas.sandberg@arm.com>2017-11-16 16:39:56 +0000
commit1033838e11ad02c4637055cf2438b4b90c5ad2a5 (patch)
tree39300538da34cc68bb4cf4d3cc246f4c5f2a7336
parent9b4e797cdd7e10ace8de83626ea844a6acabcafb (diff)
downloadgem5-1033838e11ad02c4637055cf2438b4b90c5ad2a5.tar.xz
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 <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/5730 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
-rw-r--r--src/sim/eventq.hh24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 6d68b4e3a..0a0405fef 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -542,28 +542,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;
};
/**