[kaffe] CVS kaffe (guilhem): Kaffe-gc fixlet.

Kaffe CVS cvs-commits at kaffe.org
Mon Feb 6 13:27:29 PST 2006


PatchSet 7116 
Date: 2006/02/06 21:09:51
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Kaffe-gc fixlet.

        * kaffe/kaffevm/kaffe-gc/gc-incremental.c
        (finaliserStarted): New global variable to acknowledge the finaliser
        has started.
        (gcInvokeFinaliser): Check whether the finaliser has started.
        (finaliserMan): Reordered a bit to ensure thread safety.

Members: 
	ChangeLog:1.4634->1.4635 
	kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.35->1.36 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4634 kaffe/ChangeLog:1.4635
--- kaffe/ChangeLog:1.4634	Mon Feb  6 19:56:28 2006
+++ kaffe/ChangeLog	Mon Feb  6 21:09:51 2006
@@ -1,5 +1,13 @@
 2006-02-06  Guilhem Lavaux  <guilhem at kaffe.org>
 
+	* kaffe/kaffevm/kaffe-gc/gc-incremental.c
+	(finaliserStarted): New global variable to acknowledge the finaliser
+	has started.
+	(gcInvokeFinaliser): Check whether the finaliser has started.
+	(finaliserMan): Reordered a bit to ensure thread safety.
+
+2006-02-06  Guilhem Lavaux  <guilhem at kaffe.org>
+
 	* libraries/javalib/vmspecific/org/metastatic/jessie/Base64.java,
 	libraries/javalib/vmspecific/org/metastatic/jessie/CertificateHandler.java,
 	libraries/javalib/vmspecific/org/metastatic/jessie/ConsoleCertificateHandler.java,
Index: kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c
diff -u kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.35 kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.36
--- kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.35	Sun Dec 18 17:54:31 2005
+++ kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c	Mon Feb  6 21:09:57 2006
@@ -78,6 +78,7 @@
 static volatile int gcDisabled = 0;
 static volatile int gcRunning = -1;
 static volatile bool finalRunning = false;
+static volatile bool finaliserStarted = false;
 #if defined(KAFFE_STATS)
 static timespent gc_time;
 static timespent sweep_time;
@@ -953,8 +954,8 @@
   Collector *gcif = (Collector*)arg;
 
   lockStaticMutex(&finman);
+  finaliserStarted = true;
   for (;;) {
-    finalRunning = false;
     while (finalRunning == false) {
       waitStaticCond(&finman, (jlong)0);
     }
@@ -964,6 +965,7 @@
     
     /* Wake up anyone waiting for the finalizer to finish */
     lockStaticMutex(&finmanend);
+    finalRunning = false;
     broadcastStaticCond(&finmanend);
     unlockStaticMutex(&finmanend);
   }
@@ -1026,22 +1028,24 @@
 void
 gcInvokeFinalizer(Collector* gcif)
 {
-
-	/* First invoke the GC */
-	KGC_invoke(gcif, 1);
-
-	/* Run the finalizer (if might already be running as a result of
-	 * the GC)
-	 */
-	lockStaticMutex(&finman);
-	if (finalRunning == false) {
-		finalRunning = true;
-		signalStaticCond(&finman); 
-	}
-	lockStaticMutex(&finmanend);
-	unlockStaticMutex(&finman);
-	waitStaticCond(&finmanend, (jlong)0);
-	unlockStaticMutex(&finmanend);
+  while (!finaliserStarted)
+    KTHREAD(yield)();
+  
+  /* First invoke the GC */
+  KGC_invoke(gcif, 1);
+  
+  /* Run the finalizer (if might already be running as a result of
+   * the GC)
+   */
+  lockStaticMutex(&finman);
+  if (finalRunning == false) {
+    finalRunning = true;
+    signalStaticCond(&finman); 
+  }
+  lockStaticMutex(&finmanend);
+  unlockStaticMutex(&finman);
+  waitStaticCond(&finmanend, (jlong)0);
+  unlockStaticMutex(&finmanend);
 }
 
 /*




More information about the kaffe mailing list