[kaffe] CVS kaffe (guilhem): KSem destruction fix.

Kaffe CVS cvs-commits at kaffe.org
Fri Oct 1 08:06:07 PDT 2004


PatchSet 5236 
Date: 2004/10/01 15:02:27
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
KSem destruction fix.

2004-09-29  Guilhem Lavaux  <guilhem at kaffe.org>

        * kaffe/kaffevm/thread.c, kaffe/kaffevm/thread.h
        (unlinkNativeAndJavaThread): Renamed to
        KaffeVM_unlinkNativeAndJavaThread.

2004-09-29  Noa Resare  <noa at resare.com>

        * kaffe/kaffevm/thread.h,
        kaffe/kaffevm/thread.c,
        kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
        kaffe/kaffevm/systems/unix-jthreads/jthread.c:
        Delay ksem destruction until after lockStaticMutex invocations

Members: 
	ChangeLog:1.2790->1.2791 
	kaffe/kaffevm/thread.c:1.73->1.74 
	kaffe/kaffevm/thread.h:1.21->1.22 
	kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.121->1.122 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.42->1.43 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2790 kaffe/ChangeLog:1.2791
--- kaffe/ChangeLog:1.2790	Wed Sep 29 19:35:38 2004
+++ kaffe/ChangeLog	Fri Oct  1 15:02:27 2004
@@ -1,5 +1,19 @@
 2004-09-29  Guilhem Lavaux  <guilhem at kaffe.org>
 
+	* kaffe/kaffevm/thread.c, kaffe/kaffevm/thread.h
+	(unlinkNativeAndJavaThread): Renamed to
+	KaffeVM_unlinkNativeAndJavaThread.
+
+2004-09-29  Noa Resare  <noa at resare.com>
+ 
+	* kaffe/kaffevm/thread.h, 
+	kaffe/kaffevm/thread.c,
+	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
+	kaffe/kaffevm/systems/unix-jthreads/jthread.c:
+ 	Delay ksem destruction until after lockStaticMutex invocations
+ 
+2004-09-29  Guilhem Lavaux  <guilhem at kaffe.org>
+
 	* kaffe/kaffe/main.c
 	(main): Added a call to MAIN_MD if available.
 
Index: kaffe/kaffe/kaffevm/thread.c
diff -u kaffe/kaffe/kaffevm/thread.c:1.73 kaffe/kaffe/kaffevm/thread.c:1.74
--- kaffe/kaffe/kaffevm/thread.c:1.73	Mon Sep 20 15:48:45 2004
+++ kaffe/kaffe/kaffevm/thread.c	Fri Oct  1 15:02:30 2004
@@ -101,9 +101,14 @@
 	thread_data->needOnStack = STACK_HIGH; 
 }
 
-static void
-unlinkNativeAndJavaThread(jthread_t thread)
+/*
+ * Destroys current thread's heavy lock and resets jniEnv. Called from
+ * the threading implementation before a thread is destroyed or reused.
+ */
+void
+KaffeVM_unlinkNativeAndJavaThread()
 {
+	jthread_t thread = jthread_current();
 	threadData *thread_data = jthread_get_data(thread);
 
 	thread_data->jniEnv = 0;
@@ -460,10 +465,14 @@
 	}
 #endif
 
-	/* Destroy this thread's heavy lock */
-	unlinkNativeAndJavaThread(jthread_current());
-
-	/* This never returns */
+	/*
+	 * This may never return. If it does return, control is returned to
+	 * the threading implementation where firstStartThread() is called.
+	 *
+	 * The threading implementation is responsible for calling
+	 * KaffeVM_unlinkNativeAndJavaThread() before killing or
+	 * reusing the thread.
+	 */
 	jthread_exit();
 }
 
Index: kaffe/kaffe/kaffevm/thread.h
diff -u kaffe/kaffe/kaffevm/thread.h:1.21 kaffe/kaffe/kaffevm/thread.h:1.22
--- kaffe/kaffe/kaffevm/thread.h:1.21	Thu Jul 29 14:24:50 2004
+++ kaffe/kaffe/kaffevm/thread.h	Fri Oct  1 15:02:30 2004
@@ -42,6 +42,7 @@
 void	finalizeThread(Hjava_lang_VMThread*);
 char*	nameThread(Hjava_lang_VMThread*);
 char*	nameNativeThread(void*);
+void	KaffeVM_unlinkNativeAndJavaThread(void);
 
 
 
Index: kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c
diff -u kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.121 kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.122
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c:1.121	Sun Sep  5 12:49:55 2004
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c	Fri Oct  1 15:02:31 2004
@@ -1895,6 +1895,7 @@
 	if (currentJThread->daemon) {
 		tdaemon--;
 	}
+	KaffeVM_unlinkNativeAndJavaThread();
 
 	assert(!(currentJThread->flags & THREAD_FLAGS_EXITING));
 	currentJThread->flags |= THREAD_FLAGS_EXITING;
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.42 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.43
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.42	Mon Sep 20 16:25:28 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	Fri Oct  1 15:02:31 2004
@@ -707,6 +707,9 @@
 
 	TUNLOCK( cur); /* ---------------------------------------------------- tLock */
 
+	/* we are done using locks now. ok to destroy ksem */
+	KaffeVM_unlinkNativeAndJavaThread();
+
 	if ( nCached >= MAX_CACHED_THREADS ){
 	  break;
 	}



More information about the kaffe mailing list