aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHemant Agrawal <Hemant@freescale.com>2015-12-16 15:14:14 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-12-16 15:17:44 +0300
commit1a7893cf034dcb0045c3f7a08559b0955b3093b5 (patch)
tree66a975f041bd72d77a2364eed9b7e3f4e328af58
parent8e1694d20324ced76e900f8d48cd7d30418b4f94 (diff)
helper: linux: add thread type in pthread_create
The exisiting helper routine only create the worker threads. However there is a need to use the same for creating the control thread as well. e.g. CLI thread. Signed-off-by: Hemant Agrawal <Hemant@freescale.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--example/classifier/odp_classifier.c2
-rw-r--r--example/generator/odp_generator.c9
-rw-r--r--example/ipsec/odp_ipsec.c2
-rw-r--r--example/packet/odp_pktio.c3
-rw-r--r--example/timer/odp_timer_test.c2
-rw-r--r--helper/include/odp/helper/linux.h5
-rw-r--r--helper/linux.c6
-rw-r--r--helper/test/odp_thread.c3
-rw-r--r--test/api_test/odp_common.c2
-rw-r--r--test/performance/odp_atomic.c2
-rw-r--r--test/performance/odp_l2fwd.c3
-rw-r--r--test/performance/odp_pktio_perf.c4
-rw-r--r--test/performance/odp_scheduling.c2
-rw-r--r--test/validation/common/odp_cunit_common.c2
14 files changed, 29 insertions, 18 deletions
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index 81e6bf0b3..6cf459684 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -533,7 +533,7 @@ int main(int argc, char *argv[])
odp_cpumask_set(&thd_mask, cpu);
odph_linux_pthread_create(&thread_tbl[i], &thd_mask,
pktio_receive_thread,
- args);
+ args, ODP_THREAD_WORKER);
cpu = odp_cpumask_next(&cpumask, cpu);
}
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 01807a0bf..f15649726 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -784,7 +784,8 @@ int main(int argc, char *argv[])
abort();
args->thread[1].mode = args->appl.mode;
odph_linux_pthread_create(&thread_tbl[1], &cpu_mask,
- gen_recv_thread, &args->thread[1]);
+ gen_recv_thread, &args->thread[1],
+ ODP_THREAD_WORKER);
tq = odp_queue_create("", ODP_QUEUE_TYPE_POLL, NULL);
if (tq == ODP_QUEUE_INVALID)
@@ -804,7 +805,8 @@ int main(int argc, char *argv[])
odp_cpumask_zero(&cpu_mask);
odp_cpumask_set(&cpu_mask, cpu_next);
odph_linux_pthread_create(&thread_tbl[0], &cpu_mask,
- gen_send_thread, &args->thread[0]);
+ gen_send_thread, &args->thread[0],
+ ODP_THREAD_WORKER);
} else {
int cpu = odp_cpumask_first(&cpumask);
@@ -849,7 +851,8 @@ int main(int argc, char *argv[])
odph_linux_pthread_create(&thread_tbl[i],
&thd_mask,
thr_run_func,
- &args->thread[i]);
+ &args->thread[i],
+ ODP_THREAD_WORKER);
cpu = odp_cpumask_next(&cpumask, cpu);
}
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index f0ff2c94d..fab10359f 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1333,7 +1333,7 @@ main(int argc, char *argv[])
* Create and init worker threads
*/
odph_linux_pthread_create(thread_tbl, &cpumask,
- pktio_thread, NULL);
+ pktio_thread, NULL, ODP_THREAD_WORKER);
/*
* If there are streams attempt to verify them else
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 239c1b038..c42331bba 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -442,7 +442,8 @@ int main(int argc, char *argv[])
odp_cpumask_set(&thd_mask, cpu);
odph_linux_pthread_create(&thread_tbl[i], &thd_mask,
thr_run_func,
- &args->thread[i]);
+ &args->thread[i],
+ ODP_THREAD_WORKER);
cpu = odp_cpumask_next(&cpumask, cpu);
}
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 8796b663b..b7a4fd238 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -479,7 +479,7 @@ int main(int argc, char *argv[])
/* Create and launch worker threads */
odph_linux_pthread_create(thread_tbl, &cpumask,
- run_thread, gbls);
+ run_thread, gbls, ODP_THREAD_WORKER);
/* Wait for worker threads to exit */
odph_linux_pthread_join(thread_tbl, num_workers);
diff --git a/helper/include/odp/helper/linux.h b/helper/include/odp/helper/linux.h
index ce61fdf64..c48b3ed04 100644
--- a/helper/include/odp/helper/linux.h
+++ b/helper/include/odp/helper/linux.h
@@ -31,6 +31,7 @@ extern "C" {
typedef struct {
void *(*start_routine) (void *); /**< The function to run */
void *arg; /**< The functions arguemnts */
+ odp_thread_type_t thr_type; /**< The thread type */
} odp_start_args_t;
/** Linux pthread state information */
@@ -59,12 +60,14 @@ typedef struct {
* @param mask CPU mask
* @param start_routine Thread start function
* @param arg Thread argument
+ * @param thr_type Thread type
*
* @return Number of threads created
*/
int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
const odp_cpumask_t *mask,
- void *(*start_routine) (void *), void *arg);
+ void *(*start_routine)(void *), void *arg,
+ odp_thread_type_t thr_type);
/**
* Waits pthreads to exit
diff --git a/helper/linux.c b/helper/linux.c
index 4a8e8b3b9..7904d5c47 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -28,7 +28,7 @@ static void *odp_run_start_routine(void *arg)
odp_start_args_t *start_args = arg;
/* ODP thread local init */
- if (odp_init_local(ODP_THREAD_WORKER)) {
+ if (odp_init_local(start_args->thr_type)) {
ODPH_ERR("Local init failed\n");
return NULL;
}
@@ -46,7 +46,8 @@ static void *odp_run_start_routine(void *arg)
int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
const odp_cpumask_t *mask_in,
- void *(*start_routine)(void *), void *arg)
+ void *(*start_routine)(void *), void *arg,
+ odp_thread_type_t thr_type)
{
int i;
int num;
@@ -88,6 +89,7 @@ int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
thread_tbl[i].start_args->start_routine = start_routine;
thread_tbl[i].start_args->arg = arg;
+ thread_tbl[i].start_args->thr_type = thr_type;
ret = pthread_create(&thread_tbl[i].thread,
&thread_tbl[i].attr,
diff --git a/helper/test/odp_thread.c b/helper/test/odp_thread.c
index 592f85624..f2f7904c9 100644
--- a/helper/test/odp_thread.c
+++ b/helper/test/odp_thread.c
@@ -61,7 +61,8 @@ int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
printf("new cpu mask: %s\n", cpumaskstr);
printf("new num worker threads: %i\n\n", num_workers);
- odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, worker_fn, NULL);
+ odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, worker_fn, NULL,
+ ODP_THREAD_WORKER);
odph_linux_pthread_join(thread_tbl, num_workers);
diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
index 681d915e6..cebaa1271 100644
--- a/test/api_test/odp_common.c
+++ b/test/api_test/odp_common.c
@@ -76,7 +76,7 @@ int odp_test_thread_create(void *func_ptr(void *), pthrd_arg *arg)
/* Create and init additional threads */
odp_cpumask_default_worker(&cpumask, arg->numthrds);
odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
- (void *)arg);
+ (void *)arg, ODP_THREAD_WORKER);
return 0;
}
diff --git a/test/performance/odp_atomic.c b/test/performance/odp_atomic.c
index 1402a0c91..054f653b7 100644
--- a/test/performance/odp_atomic.c
+++ b/test/performance/odp_atomic.c
@@ -286,7 +286,7 @@ int odp_test_thread_create(void *func_ptr(void *), pthrd_arg *arg)
/* Create and init additional threads */
odp_cpumask_default_worker(&cpumask, arg->numthrds);
odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
- (void *)arg);
+ (void *)arg, ODP_THREAD_WORKER);
return 0;
}
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 3941c50f6..481fb01d2 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -598,7 +598,8 @@ int main(int argc, char *argv[])
odp_cpumask_set(&thd_mask, cpu);
odph_linux_pthread_create(&thread_tbl[i], &thd_mask,
thr_run_func,
- &gbl_args->thread[i]);
+ &gbl_args->thread[i],
+ ODP_THREAD_WORKER);
cpu = odp_cpumask_next(&cpumask, cpu);
}
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index ffe98448c..82dcf19c1 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -629,7 +629,7 @@ static int run_test_single(odp_cpumask_t *thd_mask_tx,
/* start receiver threads first */
args_rx.batch_len = gbl_args->args.rx_batch_len;
odph_linux_pthread_create(&thd_tbl[0], thd_mask_rx,
- run_thread_rx, &args_rx);
+ run_thread_rx, &args_rx, ODP_THREAD_WORKER);
odp_barrier_wait(&gbl_args->rx_barrier);
num_rx_workers = odp_cpumask_count(thd_mask_rx);
@@ -639,7 +639,7 @@ static int run_test_single(odp_cpumask_t *thd_mask_tx,
args_tx.duration = gbl_args->args.duration;
args_tx.batch_len = gbl_args->args.tx_batch_len;
odph_linux_pthread_create(&thd_tbl[num_rx_workers], thd_mask_tx,
- run_thread_tx, &args_tx);
+ run_thread_tx, &args_tx, ODP_THREAD_WORKER);
odp_barrier_wait(&gbl_args->tx_barrier);
/* wait for transmitter threads to terminate */
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index cb865b35b..971d19b05 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -995,7 +995,7 @@ int main(int argc, char *argv[])
} else {
/* Create and launch worker threads */
odph_linux_pthread_create(thread_tbl, &cpumask,
- run_thread, NULL);
+ run_thread, NULL, ODP_THREAD_WORKER);
/* Wait for worker threads to terminate */
odph_linux_pthread_join(thread_tbl, num_workers);
diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index bc786ec4d..a886f10fd 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -33,7 +33,7 @@ int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg)
odp_cpumask_default_worker(&cpumask, arg->numthrds);
return odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
- (void *)arg);
+ (void *)arg, ODP_THREAD_WORKER);
}
/** exit from test thread */