Hello,
I wrote a small patch to implement the missing bits for FreeBSD required
in the RTS to do proper threading. (FreeBSD 7.1 or later required.) I
am not sure whether I covered all the missing parts, however the patch
already reduced the number of unexpectedly failing test cases when
validating. (By the way, the validate script hangs around test #2483
(throwto001), but that will be the topic of another patch... :))
Cheers,
:g
--- configure.ac.orig 2010-05-23 01:13:40.000000000 +0200
+++ configure.ac 2010-05-23 01:23:49.432270798 +0200
@@ -650,7 +650,7 @@
AC_SYS_LARGEFILE
dnl ** check for specific header (.h) files that we are interested in
-AC_CHECK_HEADERS([bfd.h ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h
limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/mman.h sys/resource.h
sys/select.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/utsname.h
sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h])
+AC_CHECK_HEADERS([bfd.h ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h
limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/cpuset.h sys/mman.h
sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timers.h sys/times.h
sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h])
dnl ** check if it is safe to include both <time.h> and <sys/time.h>
AC_HEADER_TIME
--- rts/posix/OSThreads.c.orig 2010-05-05 17:07:35.000000000 +0200
+++ rts/posix/OSThreads.c 2010-05-23 01:49:08.573632061 +0200
@@ -24,7 +24,7 @@
#include <string.h>
#endif
-#if defined(darwin_HOST_OS)
+#if defined(darwin_HOST_OS) || defined(freebsd_HOST_OS)
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
@@ -37,6 +37,11 @@
#include <sched.h>
#endif
+#if defined(HAVE_SYS_CPUSET_H)
+#include <sys/param.h>
+#include <sys/cpuset.h>
+#endif
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -208,7 +213,7 @@
nproc = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF)
nproc = sysconf(_SC_NPROCESSORS_CONF);
-#elif defined(darwin_HOST_OS)
+#elif defined(darwin_HOST_OS) || defined(freebsd_HOST_OS)
size_t size = sizeof(nat);
if(0 != sysctlbyname("hw.ncpu",&nproc,&size,NULL,0))
nproc = 1;
@@ -252,7 +257,21 @@
(thread_policy_t) &policy,
THREAD_AFFINITY_POLICY_COUNT);
}
+#elif defined(HAVE_SYS_CPUSET_H) /* FreeBSD 7.1+ */
+void
+setThreadAffinity (nat n, nat m)
+{
+ nat nproc;
+ cpuset_t cs;
+ nat i;
+ nproc = getNumberOfProcessors();
+ CPU_ZERO(&cs);
+ for (i = n; i < nproc; i+=m) {
+ CPU_SET(i, &cs);
+ }
+ cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t),
&cs);
+}
#else
void
setThreadAffinity (nat n GNUC3_ATTRIBUTE(__unused__),
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc