[kaffe] CVS kaffe (guilhem): Fix for waitPid on pthreads.

Kaffe CVS cvs-commits at kaffe.org
Tue Jan 4 12:17:03 PST 2005


PatchSet 5750 
Date: 2005/01/04 18:11:46
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fix for waitPid on pthreads.

        * kaffe/kaffevm/systems/unix-pthreads/lock-impl.c,
        kaffe/kaffevm/systems/unix-pthreads/lock-impl.h:
        (KaffePThread_setBlockingCall, KaffePThread_clearBlockingCall):
        Defined two external functions to handle blocking syscalls (not
        interruptible by a signal).

        * kaffe/kaffevm/systems/unix-pthreads/syscalls.c
        (jthreadedWaitPid): Advertise the thread subsystem that we cannot
        receive any suspend signal in that syscall.

        * kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
        kaffe/kaffevm/systems/unix-pthreads/thread-internal.h: Handle the
        new blocking state.

Members: 
	ChangeLog:1.3294->1.3295 
	kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.15->1.16 
	kaffe/kaffevm/systems/unix-pthreads/lock-impl.h:1.8->1.9 
	kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.27->1.28 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.65->1.66 
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.29->1.30 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3294 kaffe/ChangeLog:1.3295
--- kaffe/ChangeLog:1.3294	Mon Jan  3 10:38:56 2005
+++ kaffe/ChangeLog	Tue Jan  4 18:11:46 2005
@@ -1,3 +1,19 @@
+2005-01-04  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/systems/unix-pthreads/lock-impl.c,
+	kaffe/kaffevm/systems/unix-pthreads/lock-impl.h:
+	(KaffePThread_setBlockingCall, KaffePThread_clearBlockingCall):
+	Defined two external functions to handle blocking syscalls (not
+	interruptible by a signal).
+
+	* kaffe/kaffevm/systems/unix-pthreads/syscalls.c
+	(jthreadedWaitPid): Advertise the thread subsystem that we cannot
+	receive any suspend signal in that syscall.
+	
+	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	
+	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h: Handle the
+	new blocking state.
+
 2005-01-03  Dalibor Topic  <robilad at kaffe.org>
 
 	* test/regression/Reflect.java: Adapted expected output to match
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.15 kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.16
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c:1.15	Sun Jan  2 19:03:33 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.c	Tue Jan  4 18:11:50 2005
@@ -48,6 +48,13 @@
   }
 }
 
+void KaffePThread_setBlockingCall(void *sigdata)
+{
+  jthread_t cur = jthread_current();
+
+  setBlockState(cur, BS_SYSCALL, (void*)&cur, (sigset_t*)sigdata);
+}
+
 static inline void
 clearBlockState(jthread_t cur, unsigned int newState, sigset_t *old_mask)
 {
@@ -75,6 +82,13 @@
   /* Here the state is not SS_PENDING_SUSPEND so releasing the signal will
    * not trigger a deadlock.
    */
+}
+
+void KaffePThread_clearBlockingCall(void *sigdata)
+{
+  jthread_t cur = jthread_current();
+
+  clearBlockState(cur, BS_SYSCALL, (sigset_t *)sigdata);
 }
 
 void
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.h
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.h:1.8 kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.h:1.9
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.h:1.8	Mon Jul 12 00:02:47 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/lock-impl.h	Tue Jan  4 18:11:50 2005
@@ -21,6 +21,9 @@
 
 /* prototypes for jmutex interfaces.  All inlined except jcondvar_wait() */
 
+extern void KaffePThread_setBlockingCall(void *sigdata);
+extern void KaffePThread_clearBlockingCall(void *sigdata);
+
 static inline void jmutex_initialise( jmutex* lk ) __UNUSED__;
 extern void jmutex_lock( jmutex* lk );
 static inline void jmutex_unlock( jmutex* lk ) __UNUSED__;
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.27 kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.28
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.27	Fri Dec 31 11:07:15 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c	Tue Jan  4 18:11:50 2005
@@ -19,6 +19,7 @@
 #include "jsyscall.h"
 #include "jsignal.h"
 #include "nets.h"
+#include "lock-impl.h"
 
 #if defined(HAVE_SYS_WAIT_H)
 #include <sys/wait.h>
@@ -751,8 +752,11 @@
 {
 #if defined(HAVE_WAITPID)
 	int npid;
+	sigset_t sigdata;
 
+	KaffePThread_setBlockingCall(&sigdata);
 	npid = waitpid(wpid, status, options);
+	KaffePThread_clearBlockingCall(&sigdata);
 	if (npid > 0) {
 		*outpid = npid;
 		return (0);
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.65 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.66
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.65	Sun Jan  2 19:03:33 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	Tue Jan  4 18:11:50 2005
@@ -303,7 +303,7 @@
 	   * timeout wait, and is not suspended, we are still safe (even though
 	   * the timeout value might effectively be a deadlock)
 	   */
-	  if ( (!t->blockState || (t->blockState == BS_CV_TO)) && !t->suspendState ){
+	  if ( (!t->blockState || (t->blockState == BS_SYSCALL) || (t->blockState == BS_CV_TO)) && !t->suspendState ){
 		life = 1;
 		break;
 	  }
@@ -620,7 +620,7 @@
     {
       pthread_cond_signal (&tid->data.sem.cv);
     }
-  else if(tid->blockState == 0)
+  else if (tid->blockState == 0 || (tid->blockState & BS_SYSCALL) != 0)
     {
       /* We need to send some signal to interrupt syscalls. */
       pthread_kill(tid->tid, sigInterrupt);
@@ -1302,7 +1302,7 @@
 
 		t->suspendState = SS_PENDING_SUSPEND;
 
-		if ((t->blockState & (BS_CV|BS_MUTEX|BS_CV_TO)) != 0)
+		if ((t->blockState & (BS_SYSCALL|BS_CV|BS_MUTEX|BS_CV_TO)) != 0)
 		  {
 		    /* The thread is already stopped.
 		     */
@@ -1393,7 +1393,7 @@
 				    t, t->suspendState, t->blockState));
 
 	      t->suspendState = SS_PENDING_RESUME;
-	      if ((t->blockState & (BS_CV|BS_CV_TO|BS_MUTEX)) == 0)
+	      if ((t->blockState & (BS_SYSCALL|BS_CV|BS_CV_TO|BS_MUTEX)) == 0)
 		{
 		  DBG (JTHREADDETAIL, dprintf("  sending sigResume\n"));
 		  status = pthread_kill( t->tid, sigResume);
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.29 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.30
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.29	Sun Jan  2 19:03:34 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h	Tue Jan  4 18:11:50 2005
@@ -47,7 +47,8 @@
   BS_THREAD          =  0x01,  /* blocked on tLock (thread system internal) */
   BS_MUTEX           =  0x02,  /* blocked on a external mutex lock */
   BS_CV              =  0x04,  /* blocked on a external convar wait */
-  BS_CV_TO           =  0x08   /* blocked on a external convar timeout wait */
+  BS_CV_TO           =  0x08,   /* blocked on a external convar timeout wait */
+  BS_SYSCALL         =  0x10  /* blocked on a real blocking syscall */
 } block_state_t;
 
 /*




More information about the kaffe mailing list