mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
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
This commit is contained in:
parent
df857fc96c
commit
f6b061cb10
2 changed files with 65 additions and 47 deletions
|
@ -31,17 +31,11 @@
|
|||
|
||||
#if defined(__QNXNTO__)
|
||||
# include <process.h>
|
||||
# include <sys/sched.h>
|
||||
# include <pthread.h>
|
||||
# include <devctl.h>
|
||||
# include <sys/dcmd_chr.h>
|
||||
#elif defined(__linux__)
|
||||
# define _GNU_SOURCE 1
|
||||
# include <sched.h>
|
||||
# if defined(__redhawk__)
|
||||
# include <cpuset.h>
|
||||
# include <mpadvise.h>
|
||||
# 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;
|
||||
|
|
65
clients/opal/models/AsyncIP_sl/sched.c
Normal file
65
clients/opal/models/AsyncIP_sl/sched.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/** Configure Scheduler
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @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 <process.h>
|
||||
# include <sys/sched.h>
|
||||
# include <devctl.h>
|
||||
# include <sys/dcmd_chr.h>
|
||||
#elif defined(__linux__)
|
||||
# define _GNU_SOURCE 1
|
||||
# include <sched.h>
|
||||
# if defined(__redhawk__)
|
||||
# include <cpuset.h>
|
||||
# include <mpadvise.h>
|
||||
# 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__ */
|
||||
}
|
Loading…
Add table
Reference in a new issue