eventq.hh (11990:5fad911cc326) eventq.hh (12040:8cd9d09aac7a)
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * Copyright (c) 2013 Mark D. Hill and David A. Wood
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 85 unchanged lines hidden (view full) ---

94 protected:
95 typedef unsigned short FlagsType;
96 typedef ::Flags<FlagsType> Flags;
97
98 static const FlagsType PublicRead = 0x003f; // public readable flags
99 static const FlagsType PublicWrite = 0x001d; // public writable flags
100 static const FlagsType Squashed = 0x0001; // has been squashed
101 static const FlagsType Scheduled = 0x0002; // has been scheduled
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * Copyright (c) 2013 Mark D. Hill and David A. Wood
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 85 unchanged lines hidden (view full) ---

94 protected:
95 typedef unsigned short FlagsType;
96 typedef ::Flags<FlagsType> Flags;
97
98 static const FlagsType PublicRead = 0x003f; // public readable flags
99 static const FlagsType PublicWrite = 0x001d; // public writable flags
100 static const FlagsType Squashed = 0x0001; // has been squashed
101 static const FlagsType Scheduled = 0x0002; // has been scheduled
102 static const FlagsType AutoDelete = 0x0004; // delete after dispatch
102 static const FlagsType Managed = 0x0004; // Use life cycle manager
103 static const FlagsType AutoDelete = Managed; // delete after dispatch
103 /**
104 * This used to be AutoSerialize. This value can't be reused
105 * without changing the checkpoint version since the flag field
106 * gets serialized.
107 */
108 static const FlagsType Reserved0 = 0x0008;
109 static const FlagsType IsExitEvent = 0x0010; // special exit event
110 static const FlagsType IsMainQueue = 0x0020; // on main event queue

--- 166 unchanged lines hidden (view full) ---

277 clearFlags()
278 {
279 flags.clear(PublicWrite);
280 }
281
282 // This function isn't really useful if TRACING_ON is not defined
283 virtual void trace(const char *action); //!< trace event activity
284
104 /**
105 * This used to be AutoSerialize. This value can't be reused
106 * without changing the checkpoint version since the flag field
107 * gets serialized.
108 */
109 static const FlagsType Reserved0 = 0x0008;
110 static const FlagsType IsExitEvent = 0x0010; // special exit event
111 static const FlagsType IsMainQueue = 0x0020; // on main event queue

--- 166 unchanged lines hidden (view full) ---

278 clearFlags()
279 {
280 flags.clear(PublicWrite);
281 }
282
283 // This function isn't really useful if TRACING_ON is not defined
284 virtual void trace(const char *action); //!< trace event activity
285
286 protected: /* Memory management */
287 /**
288 * @{
289 * Memory management hooks for events that have the Managed flag set
290 *
291 * Events can use automatic memory management by setting the
292 * Managed flag. The default implementation automatically deletes
293 * events once they have been removed from the event queue. This
294 * typically happens when events are descheduled or have been
295 * triggered and not rescheduled.
296 *
297 * The methods below may be overridden by events that need custom
298 * memory management. For example, events exported to Python need
299 * to impement reference counting to ensure that the Python
300 * implementation of the event is kept alive while it lives in the
301 * event queue.
302 *
303 * @note Memory managers are responsible for implementing
304 * reference counting (by overriding both acquireImpl() and
305 * releaseImpl()) or checking if an event is no longer scheduled
306 * in releaseImpl() before deallocating it.
307 */
308
309 /**
310 * Managed event scheduled and being held in the event queue.
311 */
312 void acquire()
313 {
314 if (flags.isSet(Event::Managed))
315 acquireImpl();
316 }
317
318 /**
319 * Managed event removed from the event queue.
320 */
321 void release() {
322 if (flags.isSet(Event::Managed))
323 releaseImpl();
324 }
325
326 virtual void acquireImpl() {}
327
328 virtual void releaseImpl() {
329 if (!scheduled())
330 delete this;
331 }
332
333 /** @} */
334
285 public:
286
287 /*
288 * Event constructor
289 * @param queue that the event gets scheduled on
290 */
291 Event(Priority p = Default_Pri, Flags f = 0)
292 : nextBin(nullptr), nextInBin(nullptr), _when(0), _priority(p),

--- 42 unchanged lines hidden (view full) ---

335
336 /// Check whether the event is squashed
337 bool squashed() const { return flags.isSet(Squashed); }
338
339 /// See if this is a SimExitEvent (without resorting to RTTI)
340 bool isExitEvent() const { return flags.isSet(IsExitEvent); }
341
342 /// Check whether this event will auto-delete
335 public:
336
337 /*
338 * Event constructor
339 * @param queue that the event gets scheduled on
340 */
341 Event(Priority p = Default_Pri, Flags f = 0)
342 : nextBin(nullptr), nextInBin(nullptr), _when(0), _priority(p),

--- 42 unchanged lines hidden (view full) ---

385
386 /// Check whether the event is squashed
387 bool squashed() const { return flags.isSet(Squashed); }
388
389 /// See if this is a SimExitEvent (without resorting to RTTI)
390 bool isExitEvent() const { return flags.isSet(IsExitEvent); }
391
392 /// Check whether this event will auto-delete
343 bool isAutoDelete() const { return flags.isSet(AutoDelete); }
393 bool isManaged() const { return flags.isSet(Managed); }
394 bool isAutoDelete() const { return isManaged(); }
344
345 /// Get the time that the event is scheduled
346 Tick when() const { return _when; }
347
348 /// Get the event priority
349 Priority priority() const { return _priority; }
350
351 //! If this is part of a GlobalEvent, return the pointer to the

--- 421 unchanged lines hidden ---
395
396 /// Get the time that the event is scheduled
397 Tick when() const { return _when; }
398
399 /// Get the event priority
400 Priority priority() const { return _priority; }
401
402 //! If this is part of a GlobalEvent, return the pointer to the

--- 421 unchanged lines hidden ---