1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| #include "cpu_sched_test.h"
|
| #include <logger.h>
|
| #include<sched.h>
| #include<ctype.h>
| #include<sys/types.h>
| #include<sys/sysinfo.h>
| #include<unistd.h>
|
| // setup the cpu set of this program to run on
| void set_cpu(int id)
| {
| cpu_set_t mask;
| CPU_ZERO(&mask);
| if (sched_getaffinity(0, sizeof(mask), &mask) == -1)
| {
| fprintf(stderr, "warning: could not get CPU affinity/n");
| }
|
| CPU_SET(id, &mask);
| if (sched_setaffinity(0, sizeof(mask), &mask) == -1)
| {
| fprintf(stderr, "warning: could not set CPU affinity/n");
| }
| }
|
| void cpu_sched()
| {
| //set_cpu(0x0003);
| }
|
|