aboutsummaryrefslogtreecommitdiff
path: root/helper
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 /helper
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>
Diffstat (limited to 'helper')
-rw-r--r--helper/include/odp/helper/linux.h5
-rw-r--r--helper/linux.c6
-rw-r--r--helper/test/odp_thread.c3
3 files changed, 10 insertions, 4 deletions
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);