mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fixed warning with invalid cast to cpu_set_t
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@56 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
541d27a896
commit
d8fa44d583
1 changed files with 14 additions and 2 deletions
16
src/utils.c
16
src/utils.c
|
@ -90,6 +90,18 @@ int resolve_addr(const char *addr, struct sockaddr_in *sa, int flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static cpu_set_t to_cpu_set_t(int set)
|
||||
{
|
||||
cpu_set_t cset;
|
||||
|
||||
for (int i = 0; i < sizeof(int) * 8; i++) {
|
||||
if (set & (1L << i))
|
||||
CPU_SET(i, &cset);
|
||||
}
|
||||
|
||||
return cset;
|
||||
}
|
||||
|
||||
void init_realtime(struct config *g)
|
||||
{
|
||||
/* Prefault stack */
|
||||
|
@ -119,9 +131,9 @@ void init_realtime(struct config *g)
|
|||
debug(3, "Set task priority to %u", g->priority);
|
||||
|
||||
/* Pin threads to CPUs by setting the affinity */
|
||||
size_t cset = g->affinity;
|
||||
cpu_set_t cset = to_cpu_set_t(g->affinity);
|
||||
pid_t pid = getpid();
|
||||
if (sched_setaffinity(pid, sizeof(cset), (const struct cpu_set_t *) &cset))
|
||||
if (sched_setaffinity(pid, sizeof(cset), &cset))
|
||||
perror("Failed to set CPU affinity");
|
||||
else
|
||||
debug(3, "Set affinity to %#x", g->affinity);
|
||||
|
|
Loading…
Add table
Reference in a new issue