sim-se: Add default to SyscallDesc constructor
[gem5.git] / src / sim / eventq_impl.hh
index c53a4da773b8471417b403bc9cee8e278a58dfd6..f0755ac8f4413845d7b673e37b021afbc458399e 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2012 The Regents of The University of Michigan
- * Copyright (c) 2012 Mark D. Hill and David A. Wood
+ * Copyright (c) 2012-2013 Mark D. Hill and David A. Wood
+ * Copyright (c) 2013 Advanced Micro Devices, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "sim/eventq.hh"
 
 inline void
-EventQueue::schedule(Event *event, Tick when)
+EventQueue::schedule(Event *event, Tick when, bool global)
 {
     assert(when >= getCurTick());
     assert(!event->scheduled());
     assert(event->initialized());
 
     event->setWhen(when, this);
-    insert(event);
+
+    // The check below is to make sure of two things
+    // a. a thread schedules local events on other queues through the asyncq
+    // b. a thread schedules global events on the asyncq, whether or not
+    //    this event belongs to this eventq. This is required to maintain
+    //    a total order amongst the global events. See global_event.{cc,hh}
+    //    for more explanation.
+    if (inParallelMode && (this != curEventQueue() || global)) {
+        asyncInsert(event);
+    } else {
+        insert(event);
+    }
     event->flags.set(Event::Scheduled);
-    if (this == &mainEventQueue)
-        event->flags.set(Event::IsMainQueue);
-    else
-        event->flags.clear(Event::IsMainQueue);
+    event->acquire();
 
     if (DTRACE(Event))
         event->trace("scheduled");
@@ -61,6 +70,7 @@ EventQueue::deschedule(Event *event)
 {
     assert(event->scheduled());
     assert(event->initialized());
+    assert(!inParallelMode || this == curEventQueue());
 
     remove(event);
 
@@ -70,8 +80,7 @@ EventQueue::deschedule(Event *event)
     if (DTRACE(Event))
         event->trace("descheduled");
 
-    if (event->flags.isSet(Event::AutoDelete))
-        delete event;
+    event->release();
 }
 
 inline void
@@ -80,18 +89,18 @@ EventQueue::reschedule(Event *event, Tick when, bool always)
     assert(when >= getCurTick());
     assert(always || event->scheduled());
     assert(event->initialized());
+    assert(!inParallelMode || this == curEventQueue());
 
-    if (event->scheduled())
+    if (event->scheduled()) {
         remove(event);
+    } else {
+        event->acquire();
+    }
 
     event->setWhen(when, this);
     insert(event);
     event->flags.clear(Event::Squashed);
     event->flags.set(Event::Scheduled);
-    if (this == &mainEventQueue)
-        event->flags.set(Event::IsMainQueue);
-    else
-        event->flags.clear(Event::IsMainQueue);
 
     if (DTRACE(Event))
         event->trace("rescheduled");