[kaffe] CVS kaffe (guilhem): Process exit fix for Darwin.

Kaffe CVS cvs-commits at kaffe.org
Mon Dec 6 13:28:22 PST 2004


PatchSet 5557 
Date: 2004/12/06 21:23:53
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Process exit fix for Darwin.

TODO: Improve thread status report. Find a way to kill threads in any circumstances.

	* kaffe/kaffevm/systems/unix-pthreads/lock-impl.c
	(clearBlockState): Check whether the thread has been killed and
	exit in that case.

	* kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
	(jthread_t): New field "status".
	(THREAD_KILL): New status for killed thread.

	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
	(jthread_create): Set status to RUNNING.
	(jthread_exit): Do not rely on pthread_cancel to kill threads.

Members: 
	ChangeLog:1.3103->1.3104 
	kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.11->1.12 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.55->1.56 
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.25->1.26 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3103 kaffe/ChangeLog:1.3104
--- kaffe/ChangeLog:1.3103	Mon Dec  6 21:20:36 2004
+++ kaffe/ChangeLog	Mon Dec  6 21:23:53 2004
@@ -1,3 +1,17 @@
+2004-12-06  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/systems/unix-pthreads/lock-impl.c
+	(clearBlockState): Check whether the thread has been killed and
+	exit in that case.
+
+	* kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
+	(jthread_t): New field "status".
+	(THREAD_KILL): New status for killed thread.
+	
+	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
+	(jthread_create): Set status to RUNNING.
+	(jthread_exit): Do not rely on pthread_cancel to kill threads.
+	
 2004-12-06  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/gnu/java/io/decode/Decoder.java,
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.11 kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.12
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.11	Sun Oct 31 14:35:38 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c	Mon Dec  6 21:23:54 2004
@@ -45,6 +45,12 @@
       cur->stackCur = NULL;
       pthread_mutex_unlock(&cur->suspendLock);
     }
+
+  /* Catch an interrupt event sent while we were being killed.
+   * This is needed for Darwin's pthreads.
+   */
+  if (cur->status == THREAD_KILL)
+    pthread_exit(0);
 }
 
 void
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.55 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.56
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.55	Mon Nov 22 17:23:49 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	Mon Dec  6 21:23:54 2004
@@ -867,6 +867,7 @@
 	nt->daemon = isDaemon;
 	nt->func = func;
 	nt->stackCur = 0;
+	nt->status = THREAD_RUNNING;
 
 #if defined(SCHEDULE_POLICY)
 	pthread_setschedparam( nt->tid, SCHEDULE_POLICY, &sp);
@@ -902,6 +903,7 @@
 	nt->stackMax     = 0;
 	nt->stackCur     = 0;
 	nt->daemon	 = isDaemon;
+	nt->status = THREAD_RUNNING;
 	pthread_mutex_init(&nt->suspendLock, NULL);
 	
 	DBG( JTHREAD, TMSG_SHORT( "create new ", nt))
@@ -1020,11 +1022,17 @@
 	   * bail out, to give them a chance to run their cleanup handlers
 	   */
 	  for ( t=cache; t != NULL; t = t->next ){
+		t->status = THREAD_KILL;
 		pthread_cancel( t->tid);
 	  }
 
 	  for ( t=activeThreads; t != NULL; t = t->next ){
 		if ( t != cur ) {
+		  /* Mark the thread as to be killed. */
+		  t->status = THREAD_KILL;
+		  /* Send an interrupt event to the remote thread. */
+		  jthread_interrupt(t);
+		  /* Cancel it to be sure it is dead. */
 		  pthread_cancel( t->tid);
 		}
 	  }
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.25 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.26
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.25	Mon Nov 22 18:15:15 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h	Mon Dec  6 21:23:54 2004
@@ -33,6 +33,7 @@
 #define THREAD_SUSPENDED	0
 #define THREAD_RUNNING		1
 #define THREAD_DEAD		2
+#define THREAD_KILL		3
 
 /* suspend states (these are exclusive) */
 typedef enum {
@@ -66,6 +67,7 @@
   /* wether this is a daemon thread */
   int			daemon;
   int                   interrupting;
+  char                  status;
 
   /* convars and mutexes aren't useful in signal handlers, semaphores are */
   repsem_t                 sem;




More information about the kaffe mailing list