@@ -48,6 +48,11 @@ void odp_linux_pthread_create(odp_linux_pthread_t
*thread_tbl,
int num, int first_core,
void *(*start_routine) (void *), void *arg);
+void odp_linux_pthread_create_single(odp_linux_pthread_t *thread_tbl,
+ int thd_tbl_idx,
+ int first_core,
+ void *(*start_routine) (void
*), void *arg);
+
/**
* Waits pthreads to exit
b/platform/linux-generic/odp_linux.c
@@ -85,6 +85,53 @@ void odp_linux_pthread_create(odp_linux_pthread_t
*thread_tbl, int num,
}
+void odp_linux_pthread_create_single(odp_linux_pthread_t *thread_tbl,
int thd_tbl_idx,
+ int first_core, void *(*start_routine) (void *), void *arg)
+{
+ int i;
+ cpu_set_t cpu_set;
+ odp_start_args_t *start_args;
+ int core_count;
+ int cpu;
+
+ core_count = odp_sys_core_count();
+
+ assert((first_core >= 0) && (first_core < core_count));
+ int core_count;
+ int cpu;
+
+ core_count = odp_sys_core_count();
+
+ assert((first_core >= 0) && (first_core < core_count));
+ assert((thd_tbl_idx >= 0) && (thd_tbl_idx <= core_count));
+
+ /* check thread_tbl idx is free for use? */
+ if(thread_tbl[thd_tbl_idx].thread != 0) {
+ //ODP_ERR("thread_tbl idx[%d] used\n", thd_tbl_idx);
+ printf("thread_tbl idx[%d] used\n", thd_tbl_idx);
+ return;
+ }
+
+ /* flush that tbl_idx only */
+ memset(thread_tbl+thd_tbl_idx, 0, sizeof(odp_linux_pthread_t));
+ i = thd_tbl_idx;
+ /* now create a thread, affine to first_core */
+ pthread_attr_init(&thread_tbl[i].attr);
+
+ CPU_ZERO(&cpu_set);
+
+ cpu = first_core % core_count;
+ CPU_SET(cpu, &cpu_set);
+
+ pthread_attr_setaffinity_np(&thread_tbl[i].attr,
+ sizeof(cpu_set_t), &cpu_set);
+
+ start_args = malloc(sizeof(odp_start_args_t));
+ memset(start_args, 0, sizeof(odp_start_args_t));
+ start_args->start_routine = start_routine;
+ start_args->arg = arg;
+
+ start_args->thr_id = odp_thread_create(cpu);
+
+ pthread_create(&thread_tbl[i].thread, &thread_tbl[i].attr,
+ odp_run_start_routine, start_args);
+}
+