libgc (a.k.a. Boehm's gc) on top of NGPT
Marijn Ros <[email protected]>
| Newsgroups | gmane.linux.ngpt.devel |
|---|---|
| Message-ID | <[email protected]> |
Today I finally found a couple of hours to install NGPT 2.0.0 and
libgc 6.1alpha5. I got the libgc test-program to work on top of
NGPT. My diff is attached, but note that it is not (yet?) integrated
with the configure-script but simply replaces linuxthreads-support
with NGPT-support. Also, I don't know anything about setjmp and
friends and found the current working code by trial-and-error.
However, it is very unstable if using more than 1 native thread. It
seems pthread_suspend_np returns EPERM every once in a while (3 out of
10 runs failed when MAXNATIVETHREADS was set to 2, 2 out of 5 when it
was set to 10). I think Hans was right when he couldn't figure out why
it is safe on a multi-processor.
And the reason I'm doing al this, mono (CVS-20020627), doesn't even
run my multi-threaded program (it gets a NullReferenceException while
opening the console, and after that the mono-handle-d goes
astray). However, it is able to compile it. And the compiler runs on
top of mono, so single-threaded programs seem to work.
So far for today, next weekend I will run more tests.
Bye,
Marijn
===File ~/libgc/libgc6.1alpha5-NGPT.diff====================
diff -ur gc6.1alpha5/linux_threads.c gc6.1alpha5-NGPT/linux_threads.c
--- gc6.1alpha5/linux_threads.c Fri May 31 19:53:26 2002
+++ gc6.1alpha5-NGPT/linux_threads.c Sun Jun 30 15:31:50 2002
@@ -75,6 +75,8 @@
# define _USING_POSIX4A_DRAFT10 1
# endif
+#include <setjmp.h>
+
# ifdef THREAD_LOCAL_ALLOC
# if !defined(USE_PTHREAD_SPECIFIC) && !defined(USE_HPUX_TLS)
# include "private/specific.h"
@@ -889,7 +891,9 @@
#if DEBUG_THREADS
GC_printf1("Sending suspend signal to 0x%x\n", p -> id);
#endif
- result = pthread_kill(p -> id, SIG_SUSPEND);
+ result = pthread_suspend_np(p->id);
+/* result = pthread_kill(p -> id, SIG_SUSPEND);
+*/
switch(result) {
case ESRCH:
/* Not really there anymore. Possible? */
@@ -900,13 +904,20 @@
default:
ABORT("pthread_kill failed");
}
+
+ /*
+ ** get the stack-pointer for the just-suspended thread
+ ** this depends havily on the sigjmpbuf layout of Linux/i386
+ */
+ p-> stack_ptr = (void*)*(((int*) pthread_getcontext_np(p->id))+JB_SP);
}
}
}
- for (i = 0; i < n_live_threads; i++) {
+/* for (i = 0; i < n_live_threads; i++) {
if (0 != sem_wait(&GC_suspend_ack_sem))
ABORT("sem_wait in handler failed");
}
+*/
# ifdef PARALLEL_MARK
GC_release_mark_lock();
# endif
@@ -939,7 +950,9 @@
#if DEBUG_THREADS
GC_printf1("Sending restart signal to 0x%x\n", p -> id);
#endif
- result = pthread_kill(p -> id, SIG_THR_RESTART);
+ result = pthread_resume_np(p->id);
+/* result = pthread_kill(p -> id, SIG_THR_RESTART);
+*/
switch(result) {
case ESRCH:
/* Not really there anymore. Possible? */
============================================================