Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / sysdep.cc @ 3e29b8a0

History | View | Annotate | Download (559 Bytes)

1 01873262 Georg Kunz
/**
2
 * OS-dependent functionality.
3
 *
4
 * Copyright (c) 2010 Mircea Gherzan <mircea.gherzan@rwth-aachen.de>
5
 */
6
7
#ifndef _GNU_SOURCE
8
# define _GNU_SOURCE        //pthread_setaffinity_np
9
#endif
10
11
#include <pthread.h>
12
#include <unistd.h>
13
14
#include "sysdep.h"
15
16
#ifdef __linux__
17
18
int thread_set_affinity(pthread_t tid, const unsigned cpu_idx)
19
{
20
    cpu_set_t cpuset;
21
22
    CPU_ZERO(&cpuset);
23
    CPU_SET(cpu_idx, &cpuset);
24
25
    return pthread_setaffinity_np(tid, sizeof(cpuset), &cpuset);
26
}
27
28
#else
29
# warning Unknown OS, cannot build sysdep routines!
30
#endif /* __linux__ */