>> + >> +static void schedule_multi_hi(void) >> +{ >> + test_case_args_t args; > > IMO, We should avoid using variables allocated from stack to share > the data between different execution context. > It will work in linux threaded run-time environment.But it will > have issues in different run-time environment like bare-metal. > IMO if any memory needs to be shared across different > execution environment should use the memory allocated from odp shared mem.
Ok, noted. > > >> + snprintf(args.name, sizeof(args.name), "sched_multi_hi"); >> + args.prio = ODP_SCHED_PRIO_HIGHEST; >> + args.func = test_schedule_multi; >> + execute_parallel(exec_template, &args); >> +} >> + >> +static void execute_parallel(void *(*start_routine) (void *), >> + test_case_args_t *test_case_args) >> +{ >> + odph_linux_pthread_t thread_tbl[MAX_WORKERS]; >> + int first_core; >> + >> + memset(thread_tbl, 0, sizeof(thread_tbl)); >> + >> + /* >> + * By default core #0 runs Linux kernel background tasks. >> + * Start mapping thread from core #1 >> + */ >> + first_core = 1; >> + >> + if (odp_sys_core_count() == 1) >> + first_core = 0; >> + >> + odph_linux_pthread_create(thread_tbl, num_workers, first_core, >> + start_routine, test_case_args); >> + >> + /* Wait for worker threads to terminate */ >> + odph_linux_pthread_join(thread_tbl, num_workers); >> +} >> + >> +static odp_buffer_pool_t test_odp_buffer_pool_init(void) >> +{ >> + void *pool_base; >> + odp_shm_t shm; >> + odp_buffer_pool_t pool; >> + >> + shm = odp_shm_reserve("msg_pool", >> + MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0); >> + >> + pool_base = odp_shm_addr(shm); >> + >> + if (NULL == pool_base) { >> + printf("Shared memory reserve failed.\n"); >> + return -1; >> + } >> + >> + pool = odp_buffer_pool_create("msg_pool", pool_base, MSG_POOL_SIZE, >> + BUF_SIZE, ODP_CACHE_LINE_SIZE, >> + ODP_BUFFER_TYPE_RAW); >> + >> + if (ODP_BUFFER_POOL_INVALID == pool) { >> + printf("Pool create failed.\n"); >> + return -1; >> + } >> + return pool; >> +} >> + >> +int schedule_test_init(void) >> +{ >> + test_args_t args; >> + odp_shm_t shm; >> + test_globals_t *globals; >> + int i, j; >> + int prios; >> + >> + if (0 != odp_init_global(NULL, NULL)) { >> + printf("odp_init_global fail.\n"); >> + return -1; >> + } >> + if (0 != odp_init_local()) { >> + printf("odp_init_local fail.\n"); >> + return -1; >> + } >> + if (ODP_BUFFER_POOL_INVALID == test_odp_buffer_pool_init()) { >> + printf("test_odp_buffer_pool_init fail.\n"); >> + return -1; >> + } >> + >> + /* A worker thread per core */ >> + num_workers = odp_sys_core_count(); >> + >> + if (args.core_count) > > args.core_count is uninitialized Yes, I missed that at first. I got it fixed now.
_______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp