From 528dea874ae6a448a8379c5067c7c4556c6cb303 Mon Sep 17 00:00:00 2001 From: David Grove Date: Wed, 8 Jan 2014 18:18:16 -0500 Subject: [PATCH] Add config option to use STGRTMIN-based signals for thread suspend/resume Change motivated by using BDWGC in the X10 runtime on systems where IBM Parallel Environment is used to launch the X10 processes. PE is already using the signals BDWCG is using for its own purposes, so we need to force the GC to use different ones to avoid a conflict. * configure.ac (sigrt-signals): Handle new option. * configure.ac (GC_USESIGRT_SIGNALS): New AC define. * include/private/gc_priv.h (SIG_SUSPEND): Force to be defined to _SIGRTMIN+6 if GC_USESIGRT_SIGNALS (Darwin is excluded anyway). * pthread_stop_world.c (SIG_THR_RESTART): Force to be defined to _SIGRTMIN+5 if GC_USESIGRT_SIGNALS; reformat code. --- configure.ac | 10 ++++++++++ include/private/gc_priv.h | 15 +++++++-------- pthread_stop_world.c | 19 +++++++++---------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index b319a8a..7458008 100644 --- a/configure.ac +++ b/configure.ac @@ -668,6 +668,16 @@ if test x"$enable_gcj_support" != xno; then AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj.]) fi +dnl Interaction with other programs that might use signals. +AC_ARG_ENABLE(sigrt-signals, + [AC_HELP_STRING([--enable-sigrt-signals], + [Force GC to use SIGRTMIN-based signals for thread suspend/resume])]) +if test x"${enable_sigrt_signals}" = xyes; then + AC_DEFINE([GC_USESIGRT_SIGNALS], 1, + [Force the GC to use signals based on SIGRTMIN+k.]) +fi + + dnl Debugging dnl --------- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 0f481e4..7903e46 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2377,14 +2377,15 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, #endif /* PARALLEL_MARK */ #if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && !defined(NACL) \ - && !defined(SIG_SUSPEND) + && !defined(GC_DARWIN_THREADS) && !defined(SIG_SUSPEND) /* We define the thread suspension signal here, so that we can refer */ /* to it in the dirty bit implementation, if necessary. Ideally we */ /* would allocate a (real-time?) signal using the standard mechanism. */ /* unfortunately, there is no standard mechanism. (There is one */ /* in Linux glibc, but it's not exported.) Thus we continue to use */ /* the same hard-coded signals we've always used. */ -# if defined(GC_LINUX_THREADS) || defined(GC_DGUX386_THREADS) +# if (defined(GC_LINUX_THREADS) || defined(GC_DGUX386_THREADS)) \ + && !defined(GC_USESIGRT_SIGNALS) # if defined(SPARC) && !defined(SIGPWR) /* SPARC/Linux doesn't properly define SIGPWR in . */ /* It is aliased to SIGLOST in asm/signal.h, though. */ @@ -2397,12 +2398,10 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, # ifndef GC_OPENBSD_UTHREADS # define SIG_SUSPEND SIGXFSZ # endif -# elif !defined(GC_DARWIN_THREADS) -# if defined(_SIGRTMIN) -# define SIG_SUSPEND _SIGRTMIN + 6 -# else -# define SIG_SUSPEND SIGRTMIN + 6 -# endif +# elif defined(_SIGRTMIN) +# define SIG_SUSPEND _SIGRTMIN + 6 +# else +# define SIG_SUSPEND SIGRTMIN + 6 # endif #endif /* GC_PTHREADS && !SIG_SUSPEND */ diff --git a/pthread_stop_world.c b/pthread_stop_world.c index e3726cd..d2a26d2 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -129,18 +129,17 @@ STATIC volatile AO_t GC_world_is_stopped = FALSE; * Note that we can't just stop a thread; we need it to save its stack * pointer(s) and acknowledge. */ - #ifndef SIG_THR_RESTART -# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) \ - || defined(GC_NETBSD_THREADS) -# ifdef _SIGRTMIN -# define SIG_THR_RESTART _SIGRTMIN + 5 -# else -# define SIG_THR_RESTART SIGRTMIN + 5 -# endif -# else +# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) \ + || defined(GC_NETBSD_THREADS) || defined(GC_USESIGRT_SIGNALS) +# ifdef _SIGRTMIN +# define SIG_THR_RESTART _SIGRTMIN + 5 +# else +# define SIG_THR_RESTART SIGRTMIN + 5 +# endif +# else # define SIG_THR_RESTART SIGXCPU -# endif +# endif #endif STATIC int GC_sig_suspend = SIG_SUSPEND; -- 2.7.4