Commit 3cee7785 authored by Andreas Schmidt's avatar Andreas Schmidt

Add THREAD_PINNING as compiler flag for the pin_thread_to_core macro.

parent 8bc97c6d
Pipeline #995 passed with stages
in 58 seconds
......@@ -24,5 +24,4 @@
#include <stdlib.h>
#include <stdbool.h>
#endif //PRRT_DEFINES_H
#include <arpa/inet.h>
#include <math.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/poll.h>
#include <assert.h>
#include "../defines.h"
#include "packet.h"
......@@ -82,14 +80,6 @@ PrrtSocket *PrrtSocket_create(const bool is_sender)
return NULL;
}
static void pin_thread_to_core(pthread_attr_t *ap, int core)
{
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(core, &cpuset);
pthread_attr_setaffinity_np(ap, sizeof(cpu_set_t), &cpuset);
}
bool PrrtSocket_bind(PrrtSocket *sock_ptr, const char *ipAddress, const uint16_t port)
{
check(port <= 65534, "Port %d cannot be bound to.", port);
......
#ifndef PRRT_COMMON_H
#define PRRT_COMMON_H
#include <sched.h>
#include <pthread.h>
#include "../proto/vdmcode/block_code.h"
int print_buffer(const char *buf, const int length);
......@@ -13,4 +15,15 @@ printf("PRRT ERROR: \n" fmt, ## args);
printf("NOT IMPLEMENTED: %s\n", args); \
exit(0)
#ifdef THREAD_PINNING
#define pin_thread_to_core(ap, core) { \
cpu_set_t cpuset; \
CPU_ZERO(&cpuset); \
CPU_SET(core, &cpuset); \
pthread_attr_setaffinity_np(ap, sizeof(cpu_set_t), &cpuset); \
}
#else
#define pin_thread_to_core(ap, core) { }
#endif
#endif //PRRT_COMMON_H
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