Instead of a separate context-switch flag, set HpLim to zero
[ghc-hetmet.git] / rts / Threads.c
index efdf772..936b90e 100644 (file)
@@ -145,8 +145,8 @@ createThread(Capability *cap, nat size)
      */
     ACQUIRE_LOCK(&sched_mutex);
     tso->id = next_thread_id++;  // while we have the mutex
-    tso->global_link = all_threads;
-    all_threads = tso;
+    tso->global_link = g0s0->threads;
+    g0s0->threads = tso;
     RELEASE_LOCK(&sched_mutex);
     
 #if defined(DIST)
@@ -505,16 +505,22 @@ unblockOne_ (Capability *cap, StgTSO *tso,
       }
       tso->cap = cap;
       appendToRunQueue(cap,tso);
-      // we're holding a newly woken thread, make sure we context switch
-      // quickly so we can migrate it if necessary.
-      context_switch = 1;
+
+      // context-switch soonish so we can migrate the new thread if
+      // necessary.  NB. not contextSwitchCapability(cap), which would
+      // force a context switch immediately.
+      cap->context_switch = 1;
   } else {
       // we'll try to wake it up on the Capability it was last on.
-      wakeupThreadOnCapability_lock(tso->cap, tso);
+      wakeupThreadOnCapability(cap, tso->cap, tso);
   }
 #else
   appendToRunQueue(cap,tso);
-  context_switch = 1;
+
+  // context-switch soonish so we can migrate the new thread if
+  // necessary.  NB. not contextSwitchCapability(cap), which would
+  // force a context switch immediately.
+  cap->context_switch = 1;
 #endif
 
   debugTrace(DEBUG_sched,
@@ -698,7 +704,7 @@ printThreadBlockage(StgTSO *tso)
     break;
 #if defined(mingw32_HOST_OS)
     case BlockedOnDoProc:
-    debugBelch("is blocked on proc (request: %ld)", tso->block_info.async_result->reqID);
+    debugBelch("is blocked on proc (request: %u)", tso->block_info.async_result->reqID);
     break;
 #endif
   case BlockedOnDelay:
@@ -763,6 +769,11 @@ printThreadStatus(StgTSO *t)
        default:
            printThreadBlockage(t);
        }
+        if (t->flags & TSO_DIRTY) {
+            debugBelch(" (TSO_DIRTY)");
+        } else if (t->flags & TSO_LINK_DIRTY) {
+            debugBelch(" (TSO_LINK_DIRTY)");
+        }
        debugBelch("\n");
     }
 }
@@ -771,7 +782,7 @@ void
 printAllThreads(void)
 {
   StgTSO *t, *next;
-  nat i;
+  nat i, s;
   Capability *cap;
 
 # if defined(GRAN)
@@ -799,7 +810,8 @@ printAllThreads(void)
   }
 
   debugBelch("other threads:\n");
-  for (t = all_threads; t != END_TSO_QUEUE; t = next) {
+  for (s = 0; s < total_steps; s++) {
+    for (t = all_steps[s].threads; t != END_TSO_QUEUE; t = next) {
       if (t->why_blocked != NotBlocked) {
          printThreadStatus(t);
       }
@@ -808,6 +820,7 @@ printAllThreads(void)
       } else {
          next = t->global_link;
       }
+    }
   }
 }