move usleep(1) to gc_thread_work() from any_work()
[ghc-hetmet.git] / rts / sm / Scav.c
index b22f244..d8d158a 100644 (file)
@@ -1076,15 +1076,12 @@ scavenge_static(void)
 
   while (1) {
       
-    ACQUIRE_SPIN_LOCK(&static_objects_sync);
-    
     /* get the next static object from the list.  Remember, there might
      * be more stuff on this list after each evacuation...
      * (static_objects is a global)
      */
-    p = static_objects;
+    p = gct->static_objects;
     if (p == END_OF_STATIC_LIST) {
-         RELEASE_SPIN_LOCK(&static_objects_sync);
          break;
     }
     
@@ -1099,11 +1096,9 @@ scavenge_static(void)
     /* Take this object *off* the static_objects list,
      * and put it on the scavenged_static_objects list.
      */
-    static_objects = *STATIC_LINK(info,p);
-    *STATIC_LINK(info,p) = scavenged_static_objects;
-    scavenged_static_objects = p;
-    
-    RELEASE_SPIN_LOCK(&static_objects_sync);
+    gct->static_objects = *STATIC_LINK(info,p);
+    *STATIC_LINK(info,p) = gct->scavenged_static_objects;
+    gct->scavenged_static_objects = p;
     
     switch (info -> type) {
       
@@ -1405,6 +1400,8 @@ scavenge_find_global_work (void)
     rtsBool flag;
     step_workspace *ws;
 
+    gct->scav_global_work++;
+
     flag = rtsFalse;
     for (s = total_steps-1; s>=0; s--)
     {
@@ -1457,6 +1454,8 @@ scavenge_find_local_work (void)
     step_workspace *ws;
     rtsBool flag;
 
+    gct->scav_local_work++;
+
     flag = rtsFalse;
     for (s = total_steps-1; s >= 0; s--) {
         if (s == 0 && RtsFlags.GcFlags.generations > 1) { 
@@ -1522,8 +1521,8 @@ loop:
     work_to_do = rtsFalse;
 
     // scavenge static objects 
-    if (major_gc && static_objects != END_OF_STATIC_LIST) {
-       IF_DEBUG(sanity, checkStaticObjects(static_objects));
+    if (major_gc && gct->static_objects != END_OF_STATIC_LIST) {
+       IF_DEBUG(sanity, checkStaticObjects(gct->static_objects));
        scavenge_static();
     }
     
@@ -1551,13 +1550,10 @@ any_work (void)
     int s;
     step_workspace *ws;
 
+    gct->any_work++;
+
     write_barrier();
 
-    // scavenge static objects 
-    if (major_gc && static_objects != END_OF_STATIC_LIST) {
-       return rtsTrue;
-    }
-    
     // scavenge objects in compacted generation
     if (mark_stack_overflowed || oldgen_scan_bd != NULL ||
        (mark_stack_bdescr != NULL && !mark_stack_empty())) {
@@ -1576,5 +1572,7 @@ any_work (void)
         if (ws->stp->todos) return rtsTrue;
     }
 
+    gct->no_work++;
+
     return rtsFalse;
 }