[netperf-dev] netperf4 commit notice r143 -
branches/glib_migration/src
raj at netperf.org
raj at netperf.org
Tue Apr 11 13:22:27 PDT 2006
Author: raj
Date: 2006-04-11 13:22:23 -0700 (Tue, 11 Apr 2006)
New Revision: 143
Added:
branches/glib_migration/src/netlib_aix.c
Modified:
branches/glib_migration/src/netlib.c
Log:
Get CPU affinity going on AIX with the bindprocessor command
Modified: branches/glib_migration/src/netlib.c
===================================================================
--- branches/glib_migration/src/netlib.c 2006-04-10 23:46:03 UTC (rev 142)
+++ branches/glib_migration/src/netlib.c 2006-04-11 20:22:23 UTC (rev 143)
@@ -36,6 +36,14 @@
#include "config.h"
#endif
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+
+#ifdef _AIX
+#include <sys/thread.h>
+#endif
+
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
@@ -1603,10 +1611,27 @@
#ifdef G_THREADS_IMPL_POSIX
/* hmm, I wonder if I have to worry about alignment */
+#ifdef _AIX
+ /* bless its heart, AIX wants its CPU binding routine to be given a
+ kernel thread ID and not a pthread id. isn't that special. */
+ test->native_thread_id_ptr = malloc(sizeof(tid_t));
+ if (test->native_thread_id_ptr) {
+ *(tid_t *)(test->native_thread_id_ptr) = thread_self();
+ }
+ if (debug) {
+ fprintf(where,"%s my thread id is %d\n",__func__,thread_self());
+ fflush(where);
+ }
+#else
test->native_thread_id_ptr = malloc(sizeof(pthread_t));
if (test->native_thread_id_ptr) {
*(pthread_t *)(test->native_thread_id_ptr) = pthread_self();
}
+ if (debug) {
+ fprintf(where,"%s my thread id is %d\n",__func__,pthread_self());
+ fflush(where);
+ }
+#endif
#else
test->native_thread_id_ptr = NULL;
#endif
@@ -1628,7 +1653,13 @@
NETPERF_THREAD_T temp_tid;
- temp_tid = g_thread_create(start_routine,data,FALSE,NULL);
+ temp_tid = g_thread_create_full(start_routine, /* what to run */
+ data, /* what it should use */
+ 0, /* default stack size */
+ FALSE, /* not joinable */
+ TRUE, /* bound - make it system scope */
+ G_THREAD_PRIORITY_NORMAL,
+ NULL);
if (NULL != temp_tid) {
rc = 0;
Added: branches/glib_migration/src/netlib_aix.c
===================================================================
--- branches/glib_migration/src/netlib_aix.c 2006-04-10 23:46:03 UTC (rev 142)
+++ branches/glib_migration/src/netlib_aix.c 2006-04-11 20:22:23 UTC (rev 143)
@@ -0,0 +1,88 @@
+static char netlib_specific_id[]="\
+@(#)(c) Copyright 2006, Hewlett-Packard Company, $Id: netlib_none.c 133 2006-04-06 21:06:23Z raj $";
+
+/*
+
+This file is part of netperf4.
+
+Netperf4 is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+Netperf4 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA.
+
+In addition, as a special exception, the copyright holders give
+permission to link the code of netperf4 with the OpenSSL project's
+"OpenSSL" library (or with modified versions of it that use the same
+license as the "OpenSSL" library), and distribute the linked
+executables. You must obey the GNU General Public License in all
+respects for all of the code used other than "OpenSSL". If you modify
+this file, you may extend this exception to your version of the file,
+but you are not obligated to do so. If you do not wish to do so,
+delete this exception statement from your version.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/processor.h>
+#include <sys/thread.h>
+
+#include "netperf.h"
+
+int
+set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where) {
+ int err, value;
+ tid_t thread_id;
+
+ NETPERF_DEBUG_ENTRY(debug,where);
+
+ thread_id = *(tid_t *)(threadid);
+ value = atoi(loc_value);
+ err = bindprocessor(BINDTHREAD, thread_id, value);
+
+ if (debug) {
+ fprintf(where,
+ "%s's call to bindprocessor with BINDTHREAD thread %d and value %d returned %d errno %d\n",
+ __func__,
+ thread_id,
+ value,
+ err,
+ errno);
+ fflush(where);
+ }
+
+ NETPERF_DEBUG_EXIT(debug,where);
+ return(NPE_SUCCESS);
+}
+
+int
+set_test_locality(test_t *test, char *loc_type, char *loc_value)
+{
+
+ int err = -1;
+
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
+ err = set_thread_locality(test->native_thread_id_ptr,
+ loc_type,
+ loc_value,
+ test->debug,
+ test->where);
+
+ NETPERF_DEBUG_EXIT(test->debug,test->where);
+
+ return(err);
+}
+
More information about the netperf-dev
mailing list