Code Review
/
deb_dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge branch 'upstream-16.11-stable' into 16.11.x
[deb_dpdk.git]
/
examples
/
performance-thread
/
pthread_shim
/
main.c
diff --git
a/examples/performance-thread/pthread_shim/main.c
b/examples/performance-thread/pthread_shim/main.c
index
f035721
..
5811cff
100644
(file)
--- a/
examples/performance-thread/pthread_shim/main.c
+++ b/
examples/performance-thread/pthread_shim/main.c
@@
-59,6
+59,10
@@
#define DEBUG_APP 0
#define HELLOW_WORLD_MAX_LTHREADS 10
#define DEBUG_APP 0
#define HELLOW_WORLD_MAX_LTHREADS 10
+#ifndef __GLIBC__ /* sched_getcpu() is glibc-specific */
+#define sched_getcpu() rte_lcore_id()
+#endif
+
__thread int print_count;
__thread pthread_mutex_t print_lock;
__thread int print_count;
__thread pthread_mutex_t print_lock;
@@
-145,8
+149,7
@@
void *helloworld_pthread(void *arg)
*/
__thread pthread_t tid[HELLOW_WORLD_MAX_LTHREADS];
*/
__thread pthread_t tid[HELLOW_WORLD_MAX_LTHREADS];
-static void initial_lthread(void *args);
-static void initial_lthread(void *args __attribute__((unused)))
+static void *initial_lthread(void *args __attribute__((unused)))
{
int lcore = (int) rte_lcore_id();
/*
{
int lcore = (int) rte_lcore_id();
/*
@@
-157,6
+160,7
@@
static void initial_lthread(void *args __attribute__((unused)))
pthread_override_set(1);
uint64_t i;
pthread_override_set(1);
uint64_t i;
+ int ret;
/* initialize mutex for shared counter */
print_count = 0;
/* initialize mutex for shared counter */
print_count = 0;
@@
-175,15
+179,18
@@
static void initial_lthread(void *args __attribute__((unused)))
* use an attribute to pass the desired lcore
*/
pthread_attr_t attr;
* use an attribute to pass the desired lcore
*/
pthread_attr_t attr;
-
cpu_
set_t cpuset;
+
rte_cpu
set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(lcore, &cpuset);
pthread_attr_init(&attr);
CPU_ZERO(&cpuset);
CPU_SET(lcore, &cpuset);
pthread_attr_init(&attr);
- pthread_attr_setaffinity_np(&attr, sizeof(
cpu_
set_t), &cpuset);
+ pthread_attr_setaffinity_np(&attr, sizeof(
rte_cpu
set_t), &cpuset);
/* create the thread */
/* create the thread */
- pthread_create(&tid[i], &attr, helloworld_pthread, (void *) i);
+ ret = pthread_create(&tid[i], &attr,
+ helloworld_pthread, (void *) i);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE, "Cannot create helloworld thread\n");
}
/* wait for 1s to allow threads
}
/* wait for 1s to allow threads
@@
-217,6
+224,7
@@
static void initial_lthread(void *args __attribute__((unused)))
/* shutdown the lthread scheduler */
lthread_scheduler_shutdown(rte_lcore_id());
lthread_detach();
/* shutdown the lthread scheduler */
lthread_scheduler_shutdown(rte_lcore_id());
lthread_detach();
+ return NULL;
}
}
@@
-227,8
+235,6
@@
static void initial_lthread(void *args __attribute__((unused)))
* in the core mask
*/
static int
* in the core mask
*/
static int
-lthread_scheduler(void *args);
-static int
lthread_scheduler(void *args __attribute__((unused)))
{
/* create initial thread */
lthread_scheduler(void *args __attribute__((unused)))
{
/* create initial thread */