diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2017-05-10 10:51:53 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2017-05-24 14:28:45 +0000 |
commit | 5b3752c37280b0ae508bda824c89810136bf9360 (patch) | |
tree | cc87a50f88396eac17c11f75d51ce3032c7fd0e5 /src/sim/eventq.cc | |
parent | 76692f360c243401a850ea74cf123d4d006113ec (diff) | |
download | gem5-5b3752c37280b0ae508bda824c89810136bf9360.tar.xz |
sim: Add hooks to implement event reference counting
We currently only support deleting an event if it is triggered and not
re-scheduled. This is fine for most native code. However, there are
cases where Python needs to count references to make sure that the
Python object stays live while the native object is live.
Generalise the mechanism used to implement by adding reference
counting hooks to the event base class:
* Event::acquire() / Event::acquireImpl()
* Event::release() / Event::releaseImpl()
These calls can be used to implement both reference counting and the
existing AutoDelete functionality. The default implementation in Event
maintains backwards compatibility with the existing AutoDelete feature
by ignoring acquireImpl() and deleting the event on releaseImpl() if
it isn't scheduled anymore.
Since AutoDelete functionality is no longer the only way events can be
managed, this change introduces the new Managed flag. This flag
activates automatic memory management. The acquireImpl()/releaseImpl()
methods are only called from acquire()/release() it is set. To
maintain backwards compatibility, AutoDelete is used as an alias for
Managed.
Change-Id: I5637984c906a9d44c22780712cf1c521b8297149
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/3221
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/sim/eventq.cc')
-rw-r--r-- | src/sim/eventq.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc index 7c2648c64..3e27bcf1c 100644 --- a/src/sim/eventq.cc +++ b/src/sim/eventq.cc @@ -227,7 +227,7 @@ EventQueue::serviceOne() event->process(); if (event->isExitEvent()) { - assert(!event->flags.isSet(Event::AutoDelete) || + assert(!event->flags.isSet(Event::Managed) || !event->flags.isSet(Event::IsMainQueue)); // would be silly return event; } @@ -235,8 +235,7 @@ EventQueue::serviceOne() event->flags.clear(Event::Squashed); } - if (event->flags.isSet(Event::AutoDelete) && !event->scheduled()) - delete event; + event->release(); return NULL; } |