From f6b061cb101741f350bb964ad94783923e91873e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 14 Jul 2014 10:47:31 +0000 Subject: [PATCH] moved scheduler setup to seperate file git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@142 8ec27952-4edc-4aab-86aa-e87bb2611832 --- clients/opal/models/AsyncIP_sl/AsyncIP.c | 47 ----------------- clients/opal/models/AsyncIP_sl/sched.c | 65 ++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 47 deletions(-) create mode 100644 clients/opal/models/AsyncIP_sl/sched.c diff --git a/clients/opal/models/AsyncIP_sl/AsyncIP.c b/clients/opal/models/AsyncIP_sl/AsyncIP.c index d4f7225df..a7cd36be2 100644 --- a/clients/opal/models/AsyncIP_sl/AsyncIP.c +++ b/clients/opal/models/AsyncIP_sl/AsyncIP.c @@ -31,17 +31,11 @@ #if defined(__QNXNTO__) # include -# include # include # include # include #elif defined(__linux__) # define _GNU_SOURCE 1 -# include -# if defined(__redhawk__) -# include -# include -# endif #endif /* This is the message format */ @@ -66,47 +60,6 @@ #define MAXSENDSIZE 64 #define MAXRECVSIZE 64 -int AssignProcToCpu0(void) -{ -#if defined(__linux__) - #if defined(__redhawk__) - int rc; - pid_t pid = getpid(); - cpuset_t *pCpuset; - - pCpuset = cpuset_alloc(); - if (NULL == pCpuset) { - fprintf(stderr, "Error allocating a cpuset\n"); - return(ENOMEM); - } - - cpuset_init(pCpuset); - cpuset_set_cpu(pCpuset, 0, 1); - - rc = mpadvise(MPA_PRC_SETBIAS, MPA_TID, pid, pCpuset); - if (MPA_FAILURE == rc) { - rc = errno; - fprintf(stderr, "Error from mpadvise, %d %s, for pid %d\n", errno, strerror(errno), pid); - cpuset_free(pCpuset); - return(rc); - } - - cpuset_free(pCpuset); - return EOK; - #else - cpu_set_t bindSet; - CPU_ZERO(&bindSet); - CPU_SET(0, &bindSet); - - /* changing process cpu affinity */ - if (sched_setaffinity(0, sizeof(cpu_set_t), &bindSet) != 0) { - fprintf(stderr, "Unable to bind the process to CPU 0. (sched_setaffinity errno %d)\n", errno ); - return EINVAL; - } - return EOK; - #endif -#endif /* __linux__ */ -} void *SendToIPPort(void * arg) { int SendID = 1; diff --git a/clients/opal/models/AsyncIP_sl/sched.c b/clients/opal/models/AsyncIP_sl/sched.c new file mode 100644 index 000000000..065bc46bf --- /dev/null +++ b/clients/opal/models/AsyncIP_sl/sched.c @@ -0,0 +1,65 @@ +/** Configure Scheduler + * + * @author Steffen Vogel + * @author Mathieu Dubé-Dallaire + * @copyright 2014, Institute for Automation of Complex Power Systems, EONERC + * @copyright 2003, OPAL-RT Technologies inc + * @file + */ + + +#if defined(__QNXNTO__) +# include +# include +# include +# include +#elif defined(__linux__) +# define _GNU_SOURCE 1 +# include +# if defined(__redhawk__) +# include +# include +# endif +#endif + +int AssignProcToCpu0(void) +{ +#if defined(__linux__) + #if defined(__redhawk__) + int rc; + pid_t pid = getpid(); + cpuset_t *pCpuset; + + pCpuset = cpuset_alloc(); + if (NULL == pCpuset) { + fprintf(stderr, "Error allocating a cpuset\n"); + return ENOMEM; + } + + cpuset_init(pCpuset); + cpuset_set_cpu(pCpuset, 0, 1); + + rc = mpadvise(MPA_PRC_SETBIAS, MPA_TID, pid, pCpuset); + if (MPA_FAILURE == rc) { + rc = errno; + fprintf(stderr, "Error from mpadvise, %d %s, for pid %d\n", errno, strerror(errno), pid); + cpuset_free(pCpuset); + return rc; + } + + cpuset_free(pCpuset); + return EOK; + #else + cpu_set_t bindSet; + CPU_ZERO(&bindSet); + CPU_SET(0, &bindSet); + + /* changing process cpu affinity */ + if (sched_setaffinity(0, sizeof(cpu_set_t), &bindSet) != 0) { + fprintf(stderr, "Unable to bind the process to CPU 0. (sched_setaffinity errno %d)\n", errno ); + return EINVAL; + } + return EOK; + #endif +#endif /* __linux__ */ +}