[project @ 2005-11-25 14:03:00 by simonmar]
[ghc-hetmet.git] / ghc / rts / Capability.h
index 2a04e41..dcab351 100644 (file)
@@ -97,12 +97,20 @@ struct Capability_ {
 #endif
 
 // These properties should be true when a Task is holding a Capability
-#define ASSERT_CAPABILITY_INVARIANTS(cap,task)                         \
+#define ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task)                    \
   ASSERT(cap->running_task != NULL && cap->running_task == task);      \
   ASSERT(task->cap == cap);                                            \
-  ASSERT(cap->run_queue_hd == END_TSO_QUEUE ?                          \
-           cap->run_queue_tl == END_TSO_QUEUE : 1);                    \
-  ASSERT(myTask() == task);                                            \
+  ASSERT_PARTIAL_CAPABILITY_INVARIANTS(cap,task)
+
+// Sometimes a Task holds a Capability, but the Task is not associated
+// with that Capability (ie. task->cap != cap).  This happens when
+// (a) a Task holds multiple Capabilities, and (b) when the current
+// Task is bound, its thread has just blocked, and it may have been
+// moved to another Capability.
+#define ASSERT_PARTIAL_CAPABILITY_INVARIANTS(cap,task) \
+  ASSERT(cap->run_queue_hd == END_TSO_QUEUE ?          \
+           cap->run_queue_tl == END_TSO_QUEUE : 1);    \
+  ASSERT(myTask() == task);                            \
   ASSERT_TASK_ID(task);
 
 // Converts a *StgRegTable into a *Capability.