[kaffe] CVS kaffe (guilhem): Fix for systems which are not supporting SCHED_OTHER (e.g. netbsd)
Kaffe CVS
cvs-commits at kaffe.org
Sun Nov 14 14:43:37 PST 2004
PatchSet 5459
Date: 2004/11/14 18:19:15
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Fix for systems which are not supporting SCHED_OTHER (e.g. netbsd)
* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
(tStartDeadlockWatchdog, jthread_setpriority, jthread_create): Only
use sched_param and related functions if SCHEDULE_POLICY is defined.
(SCHEDULE_POLICY): Only define if SCHED_OTHER is available.
* configure.ac: Check for SCHED_OTHER in sched.h
* configure, config/config.h.in: Regenerated.
Members:
ChangeLog:1.3005->1.3006
configure:1.391->1.392
configure.ac:1.86->1.87
config/config.h.in:1.128->1.129
kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.53->1.54
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3005 kaffe/ChangeLog:1.3006
--- kaffe/ChangeLog:1.3005 Sun Nov 14 18:02:22 2004
+++ kaffe/ChangeLog Sun Nov 14 18:19:15 2004
@@ -1,3 +1,14 @@
+2004-11-14 Guilhem Lavaux <guilhem at kaffe.org>
+
+ * kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
+ (tStartDeadlockWatchdog, jthread_setpriority, jthread_create): Only
+ use sched_param and related functions if SCHEDULE_POLICY is defined.
+ (SCHEDULE_POLICY): Only define if SCHED_OTHER is available.
+
+ * configure.ac: Check for SCHED_OTHER in sched.h
+
+ * configure, config/config.h.in: Regenerated.
+
2004-11-14 Mark Wielaard <mark at klomp.org>
libraries/clib/nio/FileChannelImpl.c
Index: kaffe/configure
diff -u kaffe/configure:1.391 kaffe/configure:1.392
--- kaffe/configure:1.391 Thu Nov 11 07:40:34 2004
+++ kaffe/configure Sun Nov 14 18:19:22 2004
@@ -46310,6 +46310,31 @@
fi
done
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <
+#include <sched.h>
+#ifdef SCHED_OTHER
+Found_SCHED_OTHER
+#endif
+ >
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "Found_SCHED_OTHER" >/dev/null 2>&1; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SCHED_OTHER_IN_SCHED 1
+_ACEOF
+
+
+fi
+rm -f conftest*
+
Index: kaffe/configure.ac
diff -u kaffe/configure.ac:1.86 kaffe/configure.ac:1.87
--- kaffe/configure.ac:1.86 Thu Nov 11 07:40:40 2004
+++ kaffe/configure.ac Sun Nov 14 18:19:36 2004
@@ -1244,6 +1244,15 @@
# at least.
AC_CHECK_FUNCS([sched_get_priority_max])
AC_CHECK_FUNCS([sched_get_priority_min])
+AC_EGREP_HEADER(Found_SCHED_OTHER,
+ [
+#include <sched.h>
+#ifdef SCHED_OTHER
+Found_SCHED_OTHER
+#endif
+ ],
+ [ AC_DEFINE(HAVE_SCHED_OTHER_IN_SCHED, 1, [Defined if SCHED_OTHER is in sched.h])
+])
dnl pthread_attr_setschedpolicy in not implemented on NetBSD <= 1.6
dnl pthread_yield is not implemented on any systems.
Index: kaffe/config/config.h.in
diff -u kaffe/config/config.h.in:1.128 kaffe/config/config.h.in:1.129
--- kaffe/config/config.h.in:1.128 Thu Nov 11 07:40:44 2004
+++ kaffe/config/config.h.in Sun Nov 14 18:19:38 2004
@@ -440,6 +440,9 @@
/* Define to 1 if you have the <sched.h> header file. */
#undef HAVE_SCHED_H
+/* Defined if SCHED_OTHER is in sched.h */
+#undef HAVE_SCHED_OTHER_IN_SCHED
+
/* Define to 1 if you have the `sched_yield' function. */
#undef HAVE_SCHED_YIELD
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.53 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.54
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.53 Fri Nov 12 18:16:13 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c Sun Nov 14 18:19:39 2004
@@ -66,7 +66,11 @@
* stringent priorities), but it usually isn't available on desktop
* OSes (or imposes certain restrictions, e.g. root privileges).
*/
+#if defined(HAVE_SCHED_OTHER_IN_SCHED)
#define SCHEDULE_POLICY SCHED_OTHER
+#else
+#undef SCHEDULE_POLICY
+#endif
/* our upper limit for cached threads (0 = no caching at all) */
#define MAX_CACHED_THREADS 0
@@ -321,12 +325,16 @@
void tStartDeadlockWatchdog (void)
{
pthread_attr_t attr;
+#if defined(SCHEDULE_POLICY)
struct sched_param sp;
sp.sched_priority = priorities[0]; /* looow */
+#endif
pthread_attr_init( &attr);
+#if defined(SCHEDULE_POLICY)
pthread_attr_setschedparam( &attr, &sp);
+#endif
pthread_attr_setstacksize( &attr, 4096);
pthread_create( &deadlockWatchdog, &attr, tWatchdogRun, 0);
@@ -461,13 +469,13 @@
int d, max, min, i;
float r;
-#if defined(HAVE_SCHED_GET_PRIORITY_MIN)
+#if defined(HAVE_SCHED_GET_PRIORITY_MIN) && defined(SCHEDULE_POLICY)
min = sched_get_priority_min( SCHEDULE_POLICY);
#else
min = 0;
#endif /* defined(HAVE_SCHED_GET_PRIORITY_MIN) */
-#if defined(HAVE_SCHED_GET_PRIORITY_MAX)
+#if defined(HAVE_SCHED_GET_PRIORITY_MAX) && defined(SCHEDULE_POLICY)
max = sched_get_priority_max( SCHEDULE_POLICY);
#else
max = 0;
@@ -817,7 +825,9 @@
{
jthread_t cur = jthread_current();
jthread_t nt;
+#if defined(SCHEDULE_POLICY)
struct sched_param sp;
+#endif
/* if we are the first one, it's seriously broken */
assert( activeThreads != 0 );
@@ -833,7 +843,9 @@
sched_yield();
}
+#if defined(SCHEDULE_POLICY)
sp.sched_priority = priorities[pri];
+#endif
protectThreadList(cur);
if ( !isDaemon )
@@ -856,7 +868,9 @@
nt->func = func;
nt->stackCur = 0;
+#if defined(SCHEDULE_POLICY)
pthread_setschedparam( nt->tid, SCHEDULE_POLICY, &sp);
+#endif
DBG( JTHREAD, TMSG_SHORT( "create recycled ", nt))
@@ -873,10 +887,12 @@
KGC_addRef(threadCollector, nt);
pthread_attr_init( &nt->attr);
+#if defined(SCHEDULE_POLICY)
pthread_attr_setschedparam( &nt->attr, &sp);
#if defined(HAVE_PTHREAD_ATTR_SETSCHEDPOLICY)
pthread_attr_setschedpolicy( &nt->attr, SCHEDULE_POLICY);
#endif /* defined(HAVE_PTHREAD_ATTR_SETSCHEDPOLICY) */
+#endif /* defined(SCHEDULE_POLICY) */
pthread_attr_setstacksize( &nt->attr, threadStackSize);
nt->data.jlThread = jlThread;
@@ -1101,6 +1117,7 @@
void
jthread_setpriority (jthread_t cur, jint prio)
{
+#if defined(SCHEDUL_POLICY)
struct sched_param sp;
if ( cur ) {
@@ -1110,6 +1127,7 @@
cur, cur->tid, cur->data.jlThread, prio, priorities[prio]))
pthread_setschedparam( cur->tid, SCHEDULE_POLICY, &sp);
}
+#endif
}
/*******************************************************************************
More information about the kaffe
mailing list