Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
3cee7785
Commit
3cee7785
authored
Jul 13, 2017
by
Andreas Schmidt
Browse files
Add THREAD_PINNING as compiler flag for the pin_thread_to_core macro.
parent
8bc97c6d
Pipeline
#995
passed with stages
in 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
prrt/defines.h
View file @
3cee7785
...
...
@@ -24,5 +24,4 @@
#include
<stdlib.h>
#include
<stdbool.h>
#endif //PRRT_DEFINES_H
prrt/proto/socket.c
View file @
3cee7785
#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
);
...
...
prrt/util/common.h
View file @
3cee7785
#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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment