Commit c7d63de1 authored by Joanne Hugé's avatar Joanne Hugé

Add CPU affinity

parent 059bcc69
......@@ -46,17 +46,24 @@ static inline uint64_t min(uint64_t a, uint64_t b);
static void *timerthread(void *p) {
struct timespec previous, current;
struct sched_param priority;
cpu_set_t mask;
uint64_t diff;
char time_measured_string[255];
thread_param_t *param = (thread_param_t *)p;
thread_stat_t *stat = &param->stat;
// Set thread priority
priority.sched_priority = param->priority;
if (sched_setscheduler(0, SCHED_FIFO, &priority))
error(EXIT_FAILURE, errno, "Couldn't set priority");
// Set thread CPU affinity
CPU_ZERO(&mask);
CPU_SET(1, &mask);
if (pthread_setaffinity_np(0, sizeof(mask), &mask) == -1)
printf("Could not set CPU affinity to CPU #1\n");
stat->max_res = 0;
stat->min_res = UINT64_MAX;
......@@ -71,7 +78,6 @@ static void *timerthread(void *p) {
diff = calcdiff_ns(current, previous);
if (param->enable_tracing && (diff > param->latency_threshold)) {
sprintf(time_measured_string, "Diff measured: %" PRIu64 "\n", diff);
tracemark(time_measured_string);
tracing(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment