Commit f37cb1d5 authored by Andreas Schmidt's avatar Andreas Schmidt

Thread pinning checks.

parent 1efe7ded
Pipeline #3166 passed with stages
in 2 minutes and 7 seconds
......@@ -183,7 +183,7 @@ bool PrrtSocket_bind(PrrtSocket *s, const char *ipAddress, const uint16_t port)
s->receiveDataThreadAttr = calloc(1, sizeof(pthread_attr_t));
if(s->isThreadPinning) {
pin_thread_to_core(s->receiveDataThreadAttr, 2);
check(pin_thread_to_core(s->receiveDataThreadAttr, 2) == EXIT_SUCCESS, "Cannot pin receive-data thread to core 2.");
}
pthread_attr_init(s->receiveDataThreadAttr);
check(pthread_create(&s->receiveDataThread, s->receiveDataThreadAttr, receive_data_loop,
......@@ -203,7 +203,7 @@ bool PrrtSocket_connect(PrrtSocket *s, const char *host, const uint16_t port) {
s->sendDataThreadAttr = calloc(1, sizeof(pthread_attr_t));
if(s->isThreadPinning) {
pin_thread_to_core(s->sendDataThreadAttr, 1);
check(pin_thread_to_core(s->sendDataThreadAttr, 1) == EXIT_SUCCESS, "Cannot pin send-data thread to core 1.");
}
pthread_attr_init(s->sendDataThreadAttr);
check(pthread_create(&s->sendDataThread, s->sendDataThreadAttr, send_data_loop,
......
......@@ -28,10 +28,10 @@ void print_gf(const gf *start, const int len) {
printf("\n");
}
void pin_thread_to_core(pthread_attr_t *ap, int core)
int 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);
return pthread_attr_setaffinity_np(ap, sizeof(cpu_set_t), &cpuset);
}
......@@ -7,7 +7,7 @@
int print_buffer(const char *buf, const int length);
void print_gf(const gf *start, const int len);
void pin_thread_to_core(pthread_attr_t *ap, int core);
int pin_thread_to_core(pthread_attr_t *ap, int core);
#define PERROR(fmt, args...) \
printf("PRRT ERROR (" __FILE__ ":%d)\n" fmt, __LINE__, ## args);
......
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