tests: use k_thread_create()

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-05-09 14:10:52 -07:00 committed by Anas Nashif
parent 0d7962cee3
commit 68d3678abb
72 changed files with 463 additions and 361 deletions

View file

@ -123,7 +123,7 @@ static pfunc func_array[] = {
(pfunc)k_uptime_delta_32,
/* thread stuff */
(pfunc)k_thread_spawn,
(pfunc)k_thread_create,
(pfunc)k_sleep,
(pfunc)k_busy_wait,
(pfunc)k_yield,

View file

@ -29,6 +29,8 @@
/* stack used by the fibers */
static char __stack thread_one_stack[STACKSIZE];
static char __stack thread_two_stack[STACKSIZE];
static struct k_thread thread_one_data;
static struct k_thread thread_two_data;
static u32_t timestamp;
@ -93,10 +95,12 @@ int coop_ctx_switch(void)
ctx_switch_balancer = 0;
bench_test_start();
k_thread_spawn(&thread_one_stack[0], STACKSIZE,
(k_thread_entry_t) thread_one, NULL, NULL, NULL, 6, 0, K_NO_WAIT);
k_thread_spawn(&thread_two_stack[0], STACKSIZE,
(k_thread_entry_t) thread_two, NULL, NULL, NULL, 6, 0, K_NO_WAIT);
k_thread_create(&thread_one_data, thread_one_stack, STACKSIZE,
(k_thread_entry_t) thread_one, NULL, NULL, NULL,
6, 0, K_NO_WAIT);
k_thread_create(&thread_two_data, thread_two_stack, STACKSIZE,
(k_thread_entry_t) thread_two, NULL, NULL, NULL,
6, 0, K_NO_WAIT);
if (ctx_switch_balancer > 3 || ctx_switch_balancer < -3) {
PRINT_FORMAT(" Balance is %d. FAILED", ctx_switch_balancer);

View file

@ -30,6 +30,7 @@ static u32_t helper_thread_iterations;
#define Y_PRIORITY 10
char __noinit __stack y_stack_area[Y_STACK_SIZE];
static struct k_thread y_thread;
/**
*
@ -63,8 +64,9 @@ void thread_switch_yield(void)
bench_test_start();
/* launch helper thread of the same priority than this routine */
k_thread_spawn(y_stack_area, Y_STACK_SIZE, yielding_thread, NULL, NULL, NULL,
Y_PRIORITY, 0, K_NO_WAIT);
k_thread_create(&y_thread, y_stack_area, Y_STACK_SIZE,
yielding_thread, NULL, NULL, NULL,
Y_PRIORITY, 0, K_NO_WAIT);
/* get initial timestamp */
timestamp = TIME_STAMP_DELTA_GET(0);

View file

@ -31,6 +31,7 @@ typedef void * (*pfunc) (void *);
/* stack used by thread */
#ifdef CONFIG_OBJECTS_THREAD
static char __stack pStack[THREAD_STACK_SIZE];
static struct k_thread objects_thread;
#endif
/* pointer array ensures specified functions are linked into the image */
@ -116,8 +117,9 @@ void main(void)
#ifdef CONFIG_OBJECTS_THREAD
/* start a trivial fiber */
k_thread_spawn(pStack, THREAD_STACK_SIZE, thread_entry, MESSAGE, (void *)func_array,
NULL, 10, 0, K_NO_WAIT);
k_thread_create(&objects_thread, pStack, THREAD_STACK_SIZE,
thread_entry, MESSAGE, (void *)func_array,
NULL, 10, 0, K_NO_WAIT);
#endif
#ifdef CONFIG_OBJECTS_WHILELOOP

View file

@ -159,11 +159,11 @@ int lifo_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, lifo_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, lifo_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, lifo_thread2,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, lifo_thread2,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -193,11 +193,11 @@ int lifo_test(void)
i = 0;
k_thread_spawn(thread_stack1, STACK_SIZE, lifo_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, lifo_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, lifo_thread3,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, lifo_thread3,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -225,7 +225,7 @@ int lifo_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, lifo_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, lifo_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {

View file

@ -159,10 +159,10 @@ int fifo_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, fifo_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, fifo_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, fifo_thread2,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, fifo_thread2,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -191,10 +191,10 @@ int fifo_test(void)
t = BENCH_START();
i = 0;
k_thread_spawn(thread_stack1, STACK_SIZE, fifo_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, fifo_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, fifo_thread3,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, fifo_thread3,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -222,10 +222,10 @@ int fifo_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, fifo_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, fifo_thread1,
NULL, (void *) (NUMBER_OF_LOOPS / 2), NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, fifo_thread1,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, fifo_thread1,
NULL, (void *) (NUMBER_OF_LOOPS / 2), NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {

View file

@ -123,10 +123,10 @@ int sema_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, sema_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, sema_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, sema_thread2,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, sema_thread2,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -148,10 +148,10 @@ int sema_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, sema_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, sema_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, sema_thread3,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, sema_thread3,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -173,7 +173,7 @@ int sema_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, sema_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, sema_thread1,
NULL, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
for (i = 0; i < NUMBER_OF_LOOPS; i++) {

View file

@ -157,10 +157,10 @@ int stack_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, stack_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, stack_thread1,
0, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, stack_thread2,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, stack_thread2,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -184,10 +184,10 @@ int stack_test(void)
t = BENCH_START();
i = 0;
k_thread_spawn(thread_stack1, STACK_SIZE, stack_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, stack_thread1,
0, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
k_thread_spawn(thread_stack2, STACK_SIZE, stack_thread3,
k_thread_create(&thread_data2, thread_stack2, STACK_SIZE, stack_thread3,
(void *) &i, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);
@ -212,7 +212,7 @@ int stack_test(void)
t = BENCH_START();
k_thread_spawn(thread_stack1, STACK_SIZE, stack_thread1,
k_thread_create(&thread_data1, thread_stack1, STACK_SIZE, stack_thread1,
0, (void *) NUMBER_OF_LOOPS, NULL,
K_PRIO_COOP(3), 0, K_NO_WAIT);

View file

@ -15,6 +15,8 @@
char __stack thread_stack1[STACK_SIZE];
char __stack thread_stack2[STACK_SIZE];
struct k_thread thread_data1;
struct k_thread thread_data2;
char Msg[256];

View file

@ -19,6 +19,8 @@
extern char thread_stack1[STACK_SIZE];
extern char thread_stack2[STACK_SIZE];
extern struct k_thread thread_data1;
extern struct k_thread thread_data2;
extern FILE *output_file;

View file

@ -73,6 +73,8 @@ k_tid_t thread_mbox_async_put_receive_tid;
#define STACK_SIZE 500
extern char __noinit __stack my_stack_area[STACK_SIZE];
extern char __noinit __stack my_stack_area_0[STACK_SIZE];
extern struct k_thread my_thread;
extern struct k_thread my_thread_0;
/* thread functions*/
void thread_producer_msgq_w_cxt_switch(void *p1, void *p2, void *p3);
@ -115,16 +117,16 @@ void msg_passing_bench(void)
int received_data = 0;
producer_w_cxt_switch_tid =
k_thread_spawn(my_stack_area, STACK_SIZE,
thread_producer_msgq_w_cxt_switch, NULL,
NULL, NULL, 2 /*priority*/, 0, 50);
k_thread_create(&my_thread, my_stack_area, STACK_SIZE,
thread_producer_msgq_w_cxt_switch, NULL,
NULL, NULL, 2 /*priority*/, 0, 50);
u32_t msg_status = k_msgq_get(&benchmark_q, &received_data, 300);
producer_wo_cxt_switch_tid =
k_thread_spawn(my_stack_area_0, STACK_SIZE,
thread_producer_msgq_wo_cxt_switch,
NULL, NULL, NULL, -2 /*priority*/, 0, 0);
k_thread_create(&my_thread_0, my_stack_area_0, STACK_SIZE,
thread_producer_msgq_wo_cxt_switch,
NULL, NULL, NULL, -2 /*priority*/, 0, 0);
k_thread_abort(producer_w_cxt_switch_tid);
k_thread_abort(producer_wo_cxt_switch_tid);
@ -136,16 +138,16 @@ void msg_passing_bench(void)
/* Msg queue for get*/
producer_get_w_cxt_switch_tid =
k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_producer_get_msgq_w_cxt_switch, NULL,
NULL, NULL, 1 /*priority*/, 0, 50);
k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_producer_get_msgq_w_cxt_switch, NULL,
NULL, NULL, 1 /*priority*/, 0, 50);
consumer_get_w_cxt_switch_tid =
k_thread_spawn(my_stack_area_0,
STACK_SIZE,
thread_consumer_get_msgq_w_cxt_switch,
NULL, NULL, NULL,
2 /*priority*/, 0, 50);
k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE,
thread_consumer_get_msgq_w_cxt_switch,
NULL, NULL, NULL,
2 /*priority*/, 0, 50);
k_sleep(2000); /* make the main thread sleep */
k_thread_abort(producer_get_w_cxt_switch_tid);
__msg_q_get_w_cxt_end_tsc = (__common_var_swap_end_tsc);
@ -168,17 +170,17 @@ void msg_passing_bench(void)
/* Msg box to benchmark sync put */
thread_mbox_sync_put_send_tid =
k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_mbox_sync_put_send,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_mbox_sync_put_send,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
thread_mbox_sync_put_receive_tid =
k_thread_spawn(my_stack_area_0,
STACK_SIZE,
thread_mbox_sync_put_receive,
NULL, NULL, NULL,
1 /*priority*/, 0, 0);
k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE,
thread_mbox_sync_put_receive,
NULL, NULL, NULL,
1 /*priority*/, 0, 0);
k_sleep(1000); /* make the main thread sleep */
mbox_sync_put_end_tsc = (__common_var_swap_end_tsc);
@ -187,16 +189,16 @@ void msg_passing_bench(void)
/* Msg box to benchmark sync get */
thread_mbox_sync_get_send_tid =
k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_mbox_sync_get_send,
NULL, NULL, NULL,
1 /*prio*/, 0, 0);
k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_mbox_sync_get_send,
NULL, NULL, NULL,
1 /*prio*/, 0, 0);
thread_mbox_sync_get_receive_tid =
k_thread_spawn(my_stack_area_0,
STACK_SIZE,
thread_mbox_sync_get_receive, NULL,
NULL, NULL, 2 /*priority*/, 0, 0);
k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE,
thread_mbox_sync_get_receive, NULL,
NULL, NULL, 2 /*priority*/, 0, 0);
k_sleep(1000); /* make the main thread sleep */
mbox_sync_get_end_tsc = (__common_var_swap_end_tsc);
@ -205,17 +207,17 @@ void msg_passing_bench(void)
/* Msg box to benchmark async put */
thread_mbox_async_put_send_tid =
k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_mbox_async_put_send,
NULL, NULL, NULL,
2 /*prio*/, 0, 0);
k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_mbox_async_put_send,
NULL, NULL, NULL,
2 /*prio*/, 0, 0);
thread_mbox_async_put_receive_tid =
k_thread_spawn(my_stack_area_0,
STACK_SIZE,
thread_mbox_async_put_receive,
NULL, NULL, NULL,
3 /*priority*/, 0, 0);
k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE,
thread_mbox_async_put_receive,
NULL, NULL, NULL,
3 /*priority*/, 0, 0);
k_sleep(1000); /* make the main thread sleep */
/*******************************************************************/
@ -436,4 +438,4 @@ void thread_mbox_async_put_receive(void *p1, void *p2, void *p3)
k_mbox_get(&benchmark_mbox, &rx_msg, &single_element_buffer, 300);
}
}

View file

@ -14,6 +14,8 @@ K_SEM_DEFINE(sem_bench_1, 0, 1);
#define STACK_SIZE 500
extern char __noinit __stack my_stack_area[STACK_SIZE];
extern char __noinit __stack my_stack_area_0[STACK_SIZE];
extern struct k_thread my_thread;
extern struct k_thread my_thread_0;
/* u64_t thread_yield_start_tsc[1000]; */
/* u64_t thread_yield_end_tsc[1000]; */
@ -44,14 +46,14 @@ void semaphore_bench(void)
/* Thread yield*/
sem0_tid = k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_sem0_test, NULL, NULL, NULL,
2 /*priority*/, 0, 0);
sem1_tid = k_thread_spawn(my_stack_area_0,
STACK_SIZE, thread_sem1_test,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
sem0_tid = k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_sem0_test, NULL, NULL, NULL,
2 /*priority*/, 0, 0);
sem1_tid = k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE, thread_sem1_test,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
k_sleep(1000);
@ -60,14 +62,14 @@ void semaphore_bench(void)
sem_end_time = (__common_var_swap_end_tsc);
u32_t sem_cycles = sem_end_time - sem_start_time;
sem0_tid = k_thread_spawn(my_stack_area,
STACK_SIZE, thread_sem0_give_test,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
sem1_tid = k_thread_spawn(my_stack_area_0,
STACK_SIZE, thread_sem1_give_test,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
sem0_tid = k_thread_create(&my_thread, my_stack_area,
STACK_SIZE, thread_sem0_give_test,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
sem1_tid = k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE, thread_sem1_give_test,
NULL, NULL, NULL,
2 /*priority*/, 0, 0);
k_sleep(1000);
sem_give_end_time = (__common_var_swap_end_tsc);
@ -180,4 +182,4 @@ void thread_sem0_give_test(void *p1, void *p2, void *p3)
sem_give_start_time = OS_GET_TIME();
k_sem_give(&sem_bench_1);
}
}

View file

@ -46,6 +46,8 @@ k_tid_t consumer_tid;
#define STACK_SIZE 500
char __noinit __stack my_stack_area[STACK_SIZE];
char __noinit __stack my_stack_area_0[STACK_SIZE];
struct k_thread my_thread;
struct k_thread my_thread_0;
u32_t __read_swap_end_tsc_value_test = 1;
u64_t dummy_time;
@ -171,11 +173,10 @@ void system_thread_bench(void)
/* to measure context switch time */
k_thread_spawn(my_stack_area_0,
STACK_SIZE,
thread_swap_test,
NULL, NULL, NULL,
-1 /*priority*/, 0, 0);
k_thread_create(&my_thread_0, my_stack_area_0, STACK_SIZE,
thread_swap_test,
NULL, NULL, NULL,
-1 /*priority*/, 0, 0);
thread_abort_end_tsc = (__common_var_swap_end_tsc);
__end_swap_tsc = __common_var_swap_end_tsc;
@ -196,11 +197,11 @@ void system_thread_bench(void)
/* thread create*/
thread_create_start_tsc = OS_GET_TIME();
k_tid_t my_tid = k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_swap_test,
NULL, NULL, NULL,
5 /*priority*/, 0, 10);
k_tid_t my_tid = k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_swap_test,
NULL, NULL, NULL,
5 /*priority*/, 0, 10);
thread_create_end_tsc = OS_GET_TIME();
@ -212,11 +213,11 @@ void system_thread_bench(void)
ARG_UNUSED(ret_value_thread_cancel);
/* Thread suspend*/
k_tid_t sus_res_tid = k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_suspend_test,
NULL, NULL, NULL,
-1 /*priority*/, 0, 0);
k_tid_t sus_res_tid = k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_suspend_test,
NULL, NULL, NULL,
-1 /*priority*/, 0, 0);
thread_suspend_end_tsc = OS_GET_TIME();
/* At this point test for resume*/
@ -344,4 +345,4 @@ void heap_malloc_free_bench(void)
(u32_t)((sum_free / count) & 0xFFFFFFFFULL),
(u32_t)(SYS_CLOCK_HW_CYCLES_TO_NS(sum_free / count)));
}
}

View file

@ -10,6 +10,8 @@ K_SEM_DEFINE(yield_sem, 0, 1);
#define STACK_SIZE 500
extern char __noinit __stack my_stack_area[STACK_SIZE];
extern char __noinit __stack my_stack_area_0[STACK_SIZE];
extern struct k_thread my_thread;
extern struct k_thread my_thread_0;
/* u64_t thread_yield_start_tsc[1000]; */
/* u64_t thread_yield_end_tsc[1000]; */
@ -34,17 +36,17 @@ void yield_bench(void)
/* Thread yield*/
yield0_tid = k_thread_spawn(my_stack_area,
STACK_SIZE,
thread_yield0_test,
NULL, NULL, NULL,
0 /*priority*/, 0, 0);
yield0_tid = k_thread_create(&my_thread, my_stack_area,
STACK_SIZE,
thread_yield0_test,
NULL, NULL, NULL,
0 /*priority*/, 0, 0);
yield1_tid = k_thread_spawn(my_stack_area_0,
STACK_SIZE,
thread_yield1_test,
NULL, NULL, NULL,
0 /*priority*/, 0, 0);
yield1_tid = k_thread_create(&my_thread_0, my_stack_area_0,
STACK_SIZE,
thread_yield1_test,
NULL, NULL, NULL,
0 /*priority*/, 0, 0);
/*read the time of start of the sleep till the swap happens */
__read_swap_end_tsc_value = 1;
@ -82,4 +84,4 @@ void thread_yield1_test(void *p1, void *p2, void *p3)
while (1) {
k_yield();
}
}
}

View file

@ -20,6 +20,7 @@
#define STACKSIZE 2048
static char __stack stack[STACKSIZE];
static struct k_thread cmd_thread;
#define CMD_QUEUED 2
static u8_t cmd_buf[CMD_QUEUED * BTP_MTU];
@ -200,8 +201,8 @@ void tester_init(void)
k_fifo_put(&avail_queue, &cmd_buf[i * BTP_MTU]);
}
k_thread_spawn(stack, STACKSIZE, cmd_handler, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, K_NO_WAIT);
k_thread_create(&cmd_thread, stack, STACKSIZE, cmd_handler,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
uart_pipe_register(k_fifo_get(&avail_queue, K_NO_WAIT),
BTP_MTU, recv_cb);

View file

@ -25,6 +25,7 @@ K_ALERT_DEFINE(kalert_pending, alert_handler1, PENDING_MAX);
K_ALERT_DEFINE(kalert_consumed, alert_handler0, PENDING_MAX);
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_alert *palert;
static volatile int handler_executed;
@ -88,7 +89,7 @@ static void thread_alert(void)
{
handler_executed = 0;
/**TESTPOINT: thread-thread sync via alert*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
alert_send();

View file

@ -34,14 +34,15 @@ static void thread(void *p1, void *p2, void *p3)
#define STACKSIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE)
static __noinit __stack char stacks[NUM_TIMEOUTS][STACKSIZE];
static struct k_thread threads[NUM_TIMEOUTS];
void timeout_order_test(void)
{
int ii, prio = k_thread_priority_get(k_current_get()) + 1;
for (ii = 0; ii < NUM_TIMEOUTS; ii++) {
(void)k_thread_spawn(stacks[ii], STACKSIZE, thread,
(void *)ii, 0, 0, prio, 0, 0);
(void)k_thread_create(&threads[ii], stacks[ii], STACKSIZE,
thread, (void *)ii, 0, 0, prio, 0, 0);
k_timer_init(&timer[ii], 0, 0);
k_sem_init(&sem[ii], 0, 1);
results[ii] = -1;

View file

@ -8,7 +8,7 @@ This test verifies that the kernel CPU and context APIs operate as expected.
APIs tested in this test set
============================
k_thread_spawn
k_thread_create
- start a helper fiber to help with k_yield() tests
- start a fiber to test fiber related functionality
@ -94,7 +94,7 @@ Thread busy waiting completed
Testing k_sleep()
thread sleeping for 50 milliseconds
thread back from sleep
Testing k_thread_spawn() without cancellation
Testing k_thread_create() without cancellation
thread (q order: 2, t/o: 500) is running
got thread (q order: 2, t/o: 500) as expected
thread (q order: 3, t/o: 750) is running
@ -109,7 +109,7 @@ Testing k_thread_spawn() without cancellation
got thread (q order: 4, t/o: 1750) as expected
thread (q order: 5, t/o: 2000) is running
got thread (q order: 5, t/o: 2000) as expected
Testing k_thread_spawn() with cancellations
Testing k_thread_create() with cancellations
cancelling [q order: 0, t/o: 1000, t/o order: 0]
thread (q order: 3, t/o: 750) is running
got (q order: 3, t/o: 750, t/o order 1) as expected

View file

@ -9,7 +9,7 @@
/*
* DESCRIPTION
* This module tests the following CPU and thread related routines:
* k_thread_spawn, k_yield(), k_is_in_isr(),
* k_thread_create, k_yield(), k_is_in_isr(),
* k_current_get(), k_cpu_idle(), k_cpu_atomic_idle(),
* irq_lock(), irq_unlock(),
* irq_offload(), irq_enable(), irq_disable(),
@ -107,6 +107,8 @@ static int thread_evidence;
static char __stack thread_stack1[THREAD_STACKSIZE];
static char __stack thread_stack2[THREAD_STACKSIZE];
static struct k_thread thread_data1;
static struct k_thread thread_data2;
static ISR_INFO isr_info;
@ -481,7 +483,7 @@ static void thread_helper(void *arg1, void *arg2, void *arg3)
* @brief Test the k_yield() routine
*
* This routine tests the k_yield() routine. It starts another thread
* (thus also testing k_thread_spawn() and checks that behaviour of
* (thus also testing k_thread_create() and checks that behaviour of
* k_yield() against the cases of there being a higher priority thread,
* a lower priority thread, and another thread of equal priority.
*
@ -507,12 +509,12 @@ static int test_k_yield(void)
self_thread_id = k_current_get();
thread_evidence = 0;
k_thread_spawn(thread_stack2, THREAD_STACKSIZE, thread_helper,
NULL, NULL, NULL,
K_PRIO_COOP(THREAD_PRIORITY - 1), 0, 0);
k_thread_create(&thread_data2, thread_stack2, THREAD_STACKSIZE,
thread_helper, NULL, NULL, NULL,
K_PRIO_COOP(THREAD_PRIORITY - 1), 0, 0);
if (thread_evidence != 0) {
/* ERROR! Helper spawned at higher */
/* ERROR! Helper created at higher */
thread_detected_error = 10; /* priority ran prematurely. */
return TC_FAIL;
}
@ -598,7 +600,7 @@ static void thread_entry(void *task_thread_id, void *arg1, void *arg2)
/*
* Timeout tests
*
* Test the k_sleep() API, as well as the k_thread_spawn() ones.
* Test the k_sleep() API, as well as the k_thread_create() ones.
*/
struct timeout_order {
@ -620,6 +622,7 @@ struct timeout_order timeouts[] = {
#define NUM_TIMEOUT_THREADS ARRAY_SIZE(timeouts)
static char __stack timeout_stacks[NUM_TIMEOUT_THREADS][THREAD_STACKSIZE];
static struct k_thread timeout_threads[NUM_TIMEOUT_THREADS];
/* a thread busy waits, then reports through a fifo */
static void test_busy_wait(void *mseconds, void *arg2, void *arg3)
@ -698,9 +701,10 @@ static int test_timeout(void)
TC_PRINT("Testing k_busy_wait()\n");
timeout = 20; /* in ms */
k_thread_spawn(timeout_stacks[0], THREAD_STACKSIZE, test_busy_wait,
(void *)(intptr_t) timeout, NULL,
NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0);
k_thread_create(&timeout_threads[0], timeout_stacks[0],
THREAD_STACKSIZE, test_busy_wait,
(void *)(intptr_t) timeout, NULL,
NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0);
rv = k_sem_take(&reply_timeout, timeout * 2);
@ -714,9 +718,10 @@ static int test_timeout(void)
TC_PRINT("Testing k_sleep()\n");
timeout = 50;
k_thread_spawn(timeout_stacks[0], THREAD_STACKSIZE, test_thread_sleep,
(void *)(intptr_t) timeout, NULL,
NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0);
k_thread_create(&timeout_threads[0], timeout_stacks[0],
THREAD_STACKSIZE, test_thread_sleep,
(void *)(intptr_t) timeout, NULL,
NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0);
rv = k_sem_take(&reply_timeout, timeout * 2);
if (rv) {
@ -725,15 +730,16 @@ static int test_timeout(void)
return TC_FAIL;
}
/* test k_thread_spawn() without cancellation */
TC_PRINT("Testing k_thread_spawn() without cancellation\n");
/* test k_thread_create() without cancellation */
TC_PRINT("Testing k_thread_create() without cancellation\n");
for (i = 0; i < NUM_TIMEOUT_THREADS; i++) {
k_thread_spawn(timeout_stacks[i], THREAD_STACKSIZE,
delayed_thread,
(void *)i,
NULL, NULL,
K_PRIO_COOP(5), 0, timeouts[i].timeout);
k_thread_create(&timeout_threads[i], timeout_stacks[i],
THREAD_STACKSIZE,
delayed_thread,
(void *)i,
NULL, NULL,
K_PRIO_COOP(5), 0, timeouts[i].timeout);
}
for (i = 0; i < NUM_TIMEOUT_THREADS; i++) {
data = k_fifo_get(&timeout_order_fifo, 750);
@ -761,8 +767,8 @@ static int test_timeout(void)
return TC_FAIL;
}
/* test k_thread_spawn() with cancellation */
TC_PRINT("Testing k_thread_spawn() with cancellations\n");
/* test k_thread_create() with cancellation */
TC_PRINT("Testing k_thread_create() with cancellations\n");
int cancellations[] = { 0, 3, 4, 6 };
int num_cancellations = ARRAY_SIZE(cancellations);
@ -773,10 +779,10 @@ static int test_timeout(void)
for (i = 0; i < NUM_TIMEOUT_THREADS; i++) {
k_tid_t id;
id = k_thread_spawn(timeout_stacks[i], THREAD_STACKSIZE,
delayed_thread,
(void *)i, NULL, NULL,
K_PRIO_COOP(5), 0, timeouts[i].timeout);
id = k_thread_create(&timeout_threads[i], timeout_stacks[i],
THREAD_STACKSIZE, delayed_thread,
(void *)i, NULL, NULL,
K_PRIO_COOP(5), 0, timeouts[i].timeout);
delayed_threads[i] = id;
}
@ -898,9 +904,9 @@ void main(void)
TC_PRINT("Spawning a thread from a task\n");
thread_evidence = 0;
k_thread_spawn(thread_stack1, THREAD_STACKSIZE, thread_entry,
k_current_get(), NULL,
NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0);
k_thread_create(&thread_data1, thread_stack1, THREAD_STACKSIZE,
thread_entry, k_current_get(), NULL,
NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0);
if (thread_evidence != 1) {
rv = TC_FAIL;

View file

@ -28,6 +28,9 @@ static char __stack offload_work_q_stack[CONFIG_OFFLOAD_WORKQUEUE_STACK_SIZE];
static char __stack stack1[STACK_SIZE];
static char __stack stack2[STACK_SIZE];
static struct k_thread thread1;
static struct k_thread thread2;
K_SEM_DEFINE(ALT_SEM, 0, UINT_MAX);
K_SEM_DEFINE(REGRESS_SEM, 0, UINT_MAX);
K_SEM_DEFINE(TEST_SEM, 0, UINT_MAX);
@ -164,13 +167,13 @@ static void init_objects(void)
static void start_threads(void)
{
k_thread_spawn(stack1, STACK_SIZE,
AlternateTask, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), 0, 0);
k_thread_create(&thread1, stack1, STACK_SIZE,
AlternateTask, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), 0, 0);
k_thread_spawn(stack2, STACK_SIZE,
RegressionTask, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), 0, 0);
k_thread_create(&thread2, stack2, STACK_SIZE,
RegressionTask, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), 0, 0);
}
void test_critical(void)

View file

@ -12,6 +12,7 @@
#define STACK_SIZE 384
static __stack char stacks[N_THREADS][STACK_SIZE];
static struct k_thread threads[N_THREADS];
static int errno_values[N_THREADS + 1] = {
0xbabef00d,
@ -60,7 +61,7 @@ void main(void)
}
for (int ii = 0; ii < N_THREADS; ii++) {
k_thread_spawn(stacks[ii], STACK_SIZE,
k_thread_create(&threads[ii], stacks[ii], STACK_SIZE,
(k_thread_entry_t) errno_fiber,
(void *) ii, (void *) errno_values[ii], NULL,
K_PRIO_PREEMPT(ii + 5), 0, K_NO_WAIT);

View file

@ -13,6 +13,7 @@
#define PRIORITY 5
static char __noinit __stack alt_stack[STACKSIZE];
static struct k_thread alt_thread;
volatile int rv;
void alt_thread1(void)
@ -50,9 +51,10 @@ void main(void)
TC_START("test_fatal");
printk("test alt thread 1: generic CPU exception\n");
k_thread_spawn(alt_stack, STACKSIZE, (k_thread_entry_t)alt_thread1,
NULL, NULL, NULL, K_PRIO_PREEMPT(PRIORITY), 0,
K_NO_WAIT);
k_thread_create(&alt_thread, alt_stack, STACKSIZE,
(k_thread_entry_t)alt_thread1,
NULL, NULL, NULL, K_PRIO_PREEMPT(PRIORITY), 0,
K_NO_WAIT);
if (rv == TC_FAIL) {
printk("thread was not aborted\n");
goto out;
@ -61,9 +63,10 @@ void main(void)
}
printk("test alt thread 2: initiate kernel oops\n");
k_thread_spawn(alt_stack, STACKSIZE, (k_thread_entry_t)alt_thread2,
NULL, NULL, NULL, K_PRIO_PREEMPT(PRIORITY), 0,
K_NO_WAIT);
k_thread_create(&alt_thread, alt_stack, STACKSIZE,
(k_thread_entry_t)alt_thread2,
NULL, NULL, NULL, K_PRIO_PREEMPT(PRIORITY), 0,
K_NO_WAIT);
if (rv == TC_FAIL) {
printk("thread was not aborted\n");
goto out;

View file

@ -14,6 +14,7 @@ K_FIFO_DEFINE(kfifo_c);
struct k_fifo fifo_c;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread thread;
static void t_cancel_wait_entry(void *p1, void *p2, void *p3)
{
@ -23,7 +24,7 @@ static void t_cancel_wait_entry(void *p1, void *p2, void *p3)
static void tfifo_thread_thread(struct k_fifo *pfifo)
{
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&thread, tstack, STACK_SIZE,
t_cancel_wait_entry, pfifo, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
u32_t start_t = k_uptime_get_32();

View file

@ -29,6 +29,7 @@ static fdata_t data_l[LIST_LEN];
static fdata_t data_sl[LIST_LEN];
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tfifo_put(struct k_fifo *pfifo)
@ -99,7 +100,7 @@ static void tfifo_thread_thread(struct k_fifo *pfifo)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-thread data passing via fifo*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, pfifo, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
tfifo_put(pfifo);

View file

@ -35,6 +35,7 @@
static fdata_t data[LIST_LEN];
static struct k_fifo fifo;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tfifo_put(struct k_fifo *pfifo)
@ -81,7 +82,7 @@ static void tfifo_read_write(struct k_fifo *pfifo)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-isr-thread data passing via fifo*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, pfifo, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);

View file

@ -28,6 +28,7 @@ struct k_lifo lifo;
static ldata_t data[LIST_LEN];
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tlifo_put(struct k_lifo *plifo)
@ -71,7 +72,7 @@ static void tlifo_thread_thread(struct k_lifo *plifo)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-thread data passing via lifo*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, plifo, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
tlifo_put(plifo);

View file

@ -35,6 +35,7 @@
static ldata_t data[LIST_LEN];
static struct k_lifo lifo;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tlifo_put(struct k_lifo *plifo)
@ -81,7 +82,7 @@ static void tlifo_read_write(struct k_lifo *plifo)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-isr-thread data passing via lifo*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, plifo, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);

View file

@ -37,6 +37,7 @@ static struct k_mbox mbox;
static k_tid_t sender_tid, receiver_tid;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema, sync_sema;
@ -214,7 +215,7 @@ static void tmbox(struct k_mbox *pmbox)
/**TESTPOINT: thread-thread data passing via mbox*/
sender_tid = k_current_get();
receiver_tid = k_thread_spawn(tstack, STACK_SIZE,
receiver_tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tmbox_entry, pmbox, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
tmbox_put(pmbox);

View file

@ -43,6 +43,7 @@
K_MEM_POOL_DEFINE(mpool1, BLK_SIZE_MIN, BLK_SIZE_MAX, BLK_NUM_MAX, BLK_ALIGN);
static char __noinit __stack tstack[THREAD_NUM][STACK_SIZE];
static struct k_thread tdata[THREAD_NUM];
static struct k_sem sync_sema;
static struct k_mem_block block_ok;
@ -85,15 +86,15 @@ void test_mpool_alloc_wait_prio(void)
* can optionally wait for one to become available
*/
/*the low-priority thread*/
tid[0] = k_thread_spawn(tstack[0], STACK_SIZE,
tid[0] = k_thread_create(&tdata[0], tstack[0], STACK_SIZE,
tmpool_alloc_wait_timeout, NULL, NULL, NULL,
K_PRIO_PREEMPT(1), 0, 0);
/*the highest-priority thread that has waited the longest*/
tid[1] = k_thread_spawn(tstack[1], STACK_SIZE,
tid[1] = k_thread_create(&tdata[1], tstack[1], STACK_SIZE,
tmpool_alloc_wait_ok, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 10);
/*the highest-priority thread that has waited shorter*/
tid[2] = k_thread_spawn(tstack[2], STACK_SIZE,
tid[2] = k_thread_create(&tdata[2], tstack[2], STACK_SIZE,
tmpool_alloc_wait_timeout, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 20);
/*relinquish CPU for above threads to start */

View file

@ -47,6 +47,7 @@
K_MEM_POOL_DEFINE(mpool1, BLK_SIZE_MIN, BLK_SIZE_MAX, BLK_NUM_MAX, BLK_ALIGN);
K_MEM_POOL_DEFINE(mpool2, BLK_SIZE_MIN, BLK_SIZE_MAX, BLK_NUM_MAX, BLK_ALIGN);
static char __noinit __stack tstack[THREAD_NUM][STACK_SIZE];
static struct k_thread tdata[THREAD_NUM];
static struct k_mem_pool *pools[POOL_NUM] = {&mpool1, &mpool2};
static struct k_sem sync_sema;
static atomic_t pool_id;
@ -84,7 +85,7 @@ void test_mpool_threadsafe(void)
/* create multiple threads to invoke same memory pool APIs*/
for (int i = 0; i < THREAD_NUM; i++) {
tid[i] = k_thread_spawn(tstack[i], STACK_SIZE,
tid[i] = k_thread_create(&tdata[i], tstack[i], STACK_SIZE,
tmpool_api, NULL, NULL, NULL,
K_PRIO_PREEMPT(1), 0, 0);
}

View file

@ -35,6 +35,7 @@
K_MEM_SLAB_DEFINE(mslab1, BLK_SIZE, BLK_NUM, BLK_ALIGN);
static char __noinit __stack tstack[THREAD_NUM][STACK_SIZE];
static struct k_thread tdata[THREAD_NUM];
static struct k_sem sync_sema;
static void *block_ok;
@ -77,15 +78,15 @@ void test_mslab_alloc_wait_prio(void)
* optionally wait for one to become available.
*/
/*the low-priority thread*/
tid[0] = k_thread_spawn(tstack[0], STACK_SIZE,
tid[0] = k_thread_create(&tdata[0], tstack[0], STACK_SIZE,
tmslab_alloc_wait_timeout, NULL, NULL, NULL,
K_PRIO_PREEMPT(1), 0, 0);
/*the highest-priority thread that has waited the longest*/
tid[1] = k_thread_spawn(tstack[1], STACK_SIZE,
tid[1] = k_thread_create(&tdata[1], tstack[1], STACK_SIZE,
tmslab_alloc_wait_ok, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 10);
/*the highest-priority thread that has waited shorter*/
tid[2] = k_thread_spawn(tstack[2], STACK_SIZE,
tid[2] = k_thread_create(&tdata[2], tstack[2], STACK_SIZE,
tmslab_alloc_wait_timeout, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 20);
/*relinquish CPU for above threads to start */

View file

@ -27,6 +27,7 @@
K_MEM_SLAB_DEFINE(mslab1, BLK_SIZE1, BLK_NUM, BLK_ALIGN);
static struct k_mem_slab mslab2, *slabs[SLAB_NUM] = {&mslab1, &mslab2};
static char __noinit __stack tstack[THREAD_NUM][STACK_SIZE];
static struct k_thread tdata[THREAD_NUM];
static char __aligned(BLK_ALIGN) tslab[BLK_SIZE2 * BLK_NUM];
static struct k_sem sync_sema;
static atomic_t slab_id;
@ -65,7 +66,7 @@ void test_mslab_threadsafe(void)
/* create multiple threads to invoke same memory slab APIs*/
for (int i = 0; i < THREAD_NUM; i++) {
tid[i] = k_thread_spawn(tstack[i], STACK_SIZE,
tid[i] = k_thread_create(&tdata[i], tstack[i], STACK_SIZE,
tmslab_api, NULL, NULL, NULL,
K_PRIO_PREEMPT(1), 0, 0);
}

View file

@ -18,6 +18,7 @@
K_MSGQ_DEFINE(kmsgq, MSG_SIZE, MSGQ_LEN, 4);
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static char __aligned(4) tbuffer[MSG_SIZE * MSGQ_LEN];
static u32_t data[MSGQ_LEN] = { MSG0, MSG1 };
static struct k_sem end_sema;
@ -74,9 +75,9 @@ static void msgq_thread(struct k_msgq *pmsgq)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-thread data passing via message queue*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
tThread_entry, pmsgq, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, pmsgq, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
put_msgq(pmsgq);
k_sem_take(&end_sema, K_FOREVER);
k_thread_abort(tid);

View file

@ -16,6 +16,7 @@
#include "test_msgq.h"
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static char __aligned(4) tbuffer[MSG_SIZE * MSGQ_LEN];
static u32_t data[MSGQ_LEN] = { MSG0, MSG1 };
@ -40,9 +41,9 @@ void test_msgq_purge_when_put(void)
zassert_equal(ret, 0, NULL);
}
/*create another thread waiting to put msg*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
tThread_entry, &msgq, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, &msgq, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_sleep(TIMEOUT >> 1);
/**TESTPOINT: msgq purge while another thread waiting to put msg*/
k_msgq_purge(&msgq);

View file

@ -227,6 +227,7 @@ void Task11(void)
}
char __noinit __stack task12_stack_area[STACKSIZE];
struct k_thread task12_thread_data;
extern void Task12(void);
/**
@ -360,9 +361,9 @@ void RegressionTask(void)
}
/* Start thread */
k_thread_spawn(task12_stack_area, STACKSIZE,
(k_thread_entry_t)Task12, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), 0, K_NO_WAIT);
k_thread_create(&task12_thread_data, task12_stack_area, STACKSIZE,
(k_thread_entry_t)Task12, NULL, NULL, NULL,
K_PRIO_PREEMPT(12), 0, K_NO_WAIT);
k_sleep(1); /* Give Task12 a chance to block on the mutex */
k_mutex_unlock(&private_mutex);

View file

@ -27,6 +27,7 @@ K_MUTEX_DEFINE(kmutex);
static struct k_mutex mutex;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static void tThread_entry_lock_forever(void *p1, void *p2, void *p3)
{
@ -58,9 +59,9 @@ static void tmutex_test_lock(struct k_mutex *pmutex,
void (*entry_fn)(void *, void *, void *))
{
k_mutex_init(pmutex);
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
entry_fn, pmutex, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
entry_fn, pmutex, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_mutex_lock(pmutex, K_FOREVER);
TC_PRINT("access resource from main thread\n");
@ -76,9 +77,9 @@ static void tmutex_test_lock_timeout(struct k_mutex *pmutex,
{
/**TESTPOINT: test k_mutex_init mutex*/
k_mutex_init(pmutex);
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
entry_fn, pmutex, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
entry_fn, pmutex, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_mutex_lock(pmutex, K_FOREVER);
TC_PRINT("access resource from main thread\n");

View file

@ -15,7 +15,9 @@ extern void phil_entry(void);
extern void object_monitor(void);
char __stack phil_stack[N_PHILOSOPHERS][STSIZE];
static struct k_thread phil_data[N_PHILOSOPHERS];
char __stack mon_stack[STSIZE];
static struct k_thread mon_data;
struct k_sem forks[N_PHILOSOPHERS];
int main(void)
@ -29,15 +31,15 @@ int main(void)
/* create philosopher threads */
for (i = 0; i < N_PHILOSOPHERS; i++) {
k_thread_spawn(&phil_stack[i][0], STSIZE,
(k_thread_entry_t)phil_entry, NULL, NULL, NULL,
K_PRIO_COOP(6), 0, K_NO_WAIT);
k_thread_create(&phil_data[i], &phil_stack[i][0], STSIZE,
(k_thread_entry_t)phil_entry, NULL, NULL, NULL,
K_PRIO_COOP(6), 0, K_NO_WAIT);
}
/* create object counter monitor thread */
k_thread_spawn(mon_stack, STSIZE,
(k_thread_entry_t)object_monitor, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, K_NO_WAIT);
k_thread_create(&mon_data, mon_stack, STSIZE,
(k_thread_entry_t)object_monitor, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, K_NO_WAIT);
return 0;
}

View file

@ -48,6 +48,7 @@ struct offload_work {
};
static char __stack coop_stack[2][COOP_STACKSIZE];
static struct k_thread coop_thread[2];
static struct k_fifo fifo;
static struct k_lifo lifo;
@ -247,11 +248,11 @@ void task_high(void)
counter = SEM_TEST_START;
k_thread_spawn(coop_stack[0], COOP_STACKSIZE,
coop_high, NULL, NULL, NULL, K_PRIO_COOP(3), 0, 0);
k_thread_create(&coop_thread[0], coop_stack[0], COOP_STACKSIZE,
coop_high, NULL, NULL, NULL, K_PRIO_COOP(3), 0, 0);
k_thread_spawn(coop_stack[1], COOP_STACKSIZE,
coop_low, NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
k_thread_create(&coop_thread[1], coop_stack[1], COOP_STACKSIZE,
coop_low, NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
counter = FIFO_TEST_START;
fifo_tests(THIRD_SECOND, &task_high_state, my_fifo_get, k_sem_take);

View file

@ -30,6 +30,7 @@ K_PIPE_DEFINE(kpipe, PIPE_LEN, 4);
static struct k_pipe pipe;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tpipe_put(struct k_pipe *ppipe)
@ -102,7 +103,7 @@ static void tpipe_thread_thread(struct k_pipe *ppipe)
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-thread data passing via pipe*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, ppipe, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
tpipe_put(ppipe);
@ -130,7 +131,7 @@ void test_pipe_block_put(void)
{
/**TESTPOINT: test k_pipe_block_put without semaphore*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_block_put, &kpipe, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_sleep(10);
@ -146,7 +147,7 @@ void test_pipe_block_put_sema(void)
k_sem_init(&sync_sema, 0, 1);
/**TESTPOINT: test k_pipe_block_put with semaphore*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_block_put, &pipe, &sync_sema, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_sleep(10);
@ -159,7 +160,7 @@ void test_pipe_block_put_sema(void)
void test_pipe_get_put(void)
{
/**TESTPOINT: test API sequence: [get, put]*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_block_put, &kpipe, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
/*get will be executed previor to put*/

View file

@ -95,6 +95,7 @@ static struct k_poll_signal wait_signal = K_POLL_SIGNAL_INITIALIZER();
struct fifo_msg wait_msg = { NULL, FIFO_MSG_VALUE };
static struct k_thread poll_wait_helper_thread;
static __stack __noinit char poll_wait_helper_stack[KB(1)];
#define TAG_0 10
@ -143,8 +144,9 @@ void test_poll_wait(void)
*/
k_thread_priority_set(k_current_get(), main_low_prio);
k_thread_spawn(poll_wait_helper_stack, KB(1), poll_wait_helper,
(void *)1, 0, 0, main_low_prio - 1, 0, 0);
k_thread_create(&poll_wait_helper_thread, poll_wait_helper_stack,
sizeof(poll_wait_helper_stack), poll_wait_helper,
(void *)1, 0, 0, main_low_prio - 1, 0, 0);
rc = k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1));
@ -193,8 +195,9 @@ void test_poll_wait(void)
*/
k_thread_priority_set(k_current_get(), main_low_prio);
k_thread_spawn(poll_wait_helper_stack, KB(1), poll_wait_helper, 0, 0, 0,
main_low_prio - 1, 0, 0);
k_thread_create(&poll_wait_helper_thread, poll_wait_helper_stack,
sizeof(poll_wait_helper_stack), poll_wait_helper,
0, 0, 0, main_low_prio - 1, 0, 0);
rc = k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1));
@ -226,8 +229,9 @@ void test_poll_wait(void)
wait_events[2].state = K_POLL_STATE_NOT_READY;
wait_signal.signaled = 0;
k_thread_spawn(poll_wait_helper_stack, KB(1), poll_wait_helper,
(void *)1, 0, 0, old_prio + 1, 0, 0);
k_thread_create(&poll_wait_helper_thread, poll_wait_helper_stack,
sizeof(poll_wait_helper_stack), poll_wait_helper,
(void *)1, 0, 0, old_prio + 1, 0, 0);
/* semaphore */
rc = k_poll(wait_events, ARRAY_SIZE(wait_events), K_SECONDS(1));
@ -296,6 +300,7 @@ static struct k_sem eaddrinuse_sem = K_SEM_INITIALIZER(eaddrinuse_sem, 0, 1);
static struct k_sem eaddrinuse_reply =
K_SEM_INITIALIZER(eaddrinuse_reply, 0, 1);
static struct k_thread eaddrinuse_hogger_thread;
static __stack __noinit char eaddrinuse_hogger_stack[KB(1)];
static void eaddrinuse_hogger(void *p1, void *p2, void *p3)
@ -332,8 +337,9 @@ void test_poll_eaddrinuse(void)
k_thread_priority_set(k_current_get(), main_low_prio);
k_thread_spawn(eaddrinuse_hogger_stack, KB(1), eaddrinuse_hogger,
0, 0, 0, main_low_prio - 1, 0, 0);
k_thread_create(&eaddrinuse_hogger_thread, eaddrinuse_hogger_stack,
sizeof(eaddrinuse_hogger_stack), eaddrinuse_hogger,
0, 0, 0, main_low_prio - 1, 0, 0);
rc = k_poll(events, ARRAY_SIZE(events), K_SECONDS(1));

View file

@ -30,6 +30,7 @@ static qdata_t data_l[LIST_LEN];
static qdata_t data_sl[LIST_LEN];
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tqueue_append(struct k_queue *pqueue)
@ -109,7 +110,7 @@ static void tqueue_thread_thread(struct k_queue *pqueue)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-thread data passing via queue*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, pqueue, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
tqueue_append(pqueue);

View file

@ -37,6 +37,7 @@ static qdata_t data[LIST_LEN];
static qdata_t data_p[LIST_LEN];
static struct k_queue queue;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tqueue_append(struct k_queue *pqueue)
@ -95,7 +96,7 @@ static void tqueue_read_write(struct k_queue *pqueue)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-isr-thread data passing via queue*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, pqueue, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);

View file

@ -27,6 +27,7 @@
K_SEM_DEFINE(ksema, SEM_INITIAL, SEM_LIMIT);
static struct k_sem sema;
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
/*entry of contexts*/
static void tIsr_entry(void *p)
@ -42,9 +43,9 @@ static void tThread_entry(void *p1, void *p2, void *p3)
static void tsema_thread_thread(struct k_sem *psem)
{
/**TESTPOINT: thread-thread sync via sema*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
tThread_entry, psem, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tThread_entry, psem, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
/*clean the spawn thread avoid side effect in next TC*/

View file

@ -27,6 +27,7 @@ K_STACK_DEFINE(kstack, STACK_LEN);
static struct k_stack stack;
static char __noinit __stack threadstack[STACK_SIZE];
static struct k_thread thread_data;
static u32_t data[STACK_LEN] = { 0xABCD, 0x1234 };
static struct k_sem end_sema;
@ -72,9 +73,9 @@ static void tstack_thread_thread(struct k_stack *pstack)
{
k_sem_init(&end_sema, 0, 1);
/**TESTPOINT: thread-thread data passing via stack*/
k_tid_t tid = k_thread_spawn(threadstack, STACK_SIZE,
tThread_entry, pstack, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_tid_t tid = k_thread_create(&thread_data, threadstack, STACK_SIZE,
tThread_entry, pstack, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
tstack_push(pstack);
k_sem_take(&end_sema, K_FOREVER);

View file

@ -102,6 +102,7 @@ void alternate_thread(void)
char __noinit __stack alt_thread_stack_area[STACKSIZE];
static struct k_thread alt_thread_data;
/**
*
@ -118,9 +119,9 @@ void main(void)
TC_PRINT("Starts %s\n", __func__);
/* Start thread */
k_thread_spawn(alt_thread_stack_area, STACKSIZE,
(k_thread_entry_t)alternate_thread, NULL, NULL, NULL,
K_PRIO_PREEMPT(PRIORITY), 0, K_NO_WAIT);
k_thread_create(&alt_thread_data, alt_thread_stack_area, STACKSIZE,
(k_thread_entry_t)alternate_thread, NULL, NULL, NULL,
K_PRIO_PREEMPT(PRIORITY), 0, K_NO_WAIT);
if (ret == TC_FAIL) {
goto errorExit;

View file

@ -31,6 +31,7 @@
#define MY_PRIORITY 5
char __noinit __stack my_stack_area[MY_STACK_SIZE];
static struct k_thread my_thread;
/* externs */
@ -206,9 +207,9 @@ void main(void)
* Start task to trigger the spurious interrupt handler
*/
TC_PRINT("Testing to see spurious handler executes properly\n");
k_thread_spawn(my_stack_area, MY_STACK_SIZE,
idt_spur_task, NULL, NULL, NULL,
MY_PRIORITY, 0, K_NO_WAIT);
k_thread_create(&my_thread, my_stack_area, MY_STACK_SIZE,
idt_spur_task, NULL, NULL, NULL,
MY_PRIORITY, 0, K_NO_WAIT);
/*
* The fiber/task should not run past where the spurious interrupt is

View file

@ -46,6 +46,9 @@ static char __stack helper_thread_stack[THREAD_STACK];
static k_tid_t test_thread_id;
static k_tid_t helper_thread_id;
static struct k_thread test_thread_data;
static struct k_thread helper_thread_data;
static bool test_failure = true; /* Assume the test will fail */
static void test_objects_init(void)
@ -185,15 +188,19 @@ void main(void)
test_objects_init();
test_thread_id = k_thread_spawn(test_thread_stack, THREAD_STACK,
(k_thread_entry_t) test_thread, 0, 0, NULL,
TEST_THREAD_PRIORITY, 0, 0);
test_thread_id = k_thread_create(&test_thread_data, test_thread_stack,
THREAD_STACK,
(k_thread_entry_t) test_thread,
0, 0, NULL, TEST_THREAD_PRIORITY,
0, 0);
TC_PRINT("Test thread started: id = %p\n", test_thread_id);
helper_thread_id = k_thread_spawn(helper_thread_stack, THREAD_STACK,
(k_thread_entry_t) helper_thread, 0, 0, NULL,
HELPER_THREAD_PRIORITY, 0, 0);
helper_thread_id = k_thread_create(&helper_thread_data,
helper_thread_stack, THREAD_STACK,
(k_thread_entry_t) helper_thread,
0, 0, NULL, HELPER_THREAD_PRIORITY,
0, 0);
TC_PRINT("Helper thread started: id = %p\n", helper_thread_id);

View file

@ -16,6 +16,7 @@
/*local variables*/
static char __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static void customdata_entry(void *p1, void *p2, void *p3)
{
@ -39,7 +40,7 @@ static void customdata_entry(void *p1, void *p2, void *p3)
*/
void test_customdata_get_set_coop(void)
{
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
customdata_entry, NULL, NULL, NULL,
K_PRIO_COOP(1), 0, 0);
k_sleep(500);
@ -55,7 +56,7 @@ void test_customdata_get_set_coop(void)
void test_customdata_get_set_preempt(void)
{
/** TESTPOINT: custom data of preempt thread */
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
customdata_entry, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, 0);
k_sleep(500);

View file

@ -14,6 +14,7 @@
#define STACK_SIZE (256 + CONFIG_TEST_EXTRA_STACKSIZE)
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static int execute_flag;
static void thread_entry(void *p1, void *p2, void *p3)
@ -41,9 +42,9 @@ void test_threads_cancel_undelayed(void)
/* spawn thread with lower priority */
int spawn_prio = cur_prio + 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
/**TESTPOINT: check cancel retcode when thread is not delayed*/
int cancel_ret = k_thread_cancel(tid);
@ -59,9 +60,9 @@ void test_threads_cancel_started(void)
/* spawn thread with lower priority */
int spawn_prio = cur_prio + 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_sleep(50);
/**TESTPOINT: check cancel retcode when thread is started*/
@ -78,9 +79,9 @@ void test_threads_cancel_delayed(void)
/* spawn thread with lower priority */
int spawn_prio = cur_prio + 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 100);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 100);
k_sleep(50);
/**TESTPOINT: check cancel retcode when thread is started*/
@ -93,9 +94,9 @@ void test_threads_cancel_delayed(void)
void test_threads_abort_self(void)
{
execute_flag = 0;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry_abort, NULL, NULL, NULL,
0, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry_abort, NULL, NULL, NULL,
0, 0, 0);
k_sleep(100);
/**TESTPOINT: spawned thread executed but abort itself*/
zassert_true(execute_flag == 1, NULL);
@ -105,18 +106,18 @@ void test_threads_abort_self(void)
void test_threads_abort_others(void)
{
execute_flag = 0;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
0, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
0, 0, 0);
k_thread_abort(tid);
k_sleep(100);
/**TESTPOINT: check not-started thread is aborted*/
zassert_true(execute_flag == 0, NULL);
tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
0, 0, 0);
tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
0, 0, 0);
k_sleep(50);
k_thread_abort(tid);
/**TESTPOINT: check running thread is aborted*/

View file

@ -16,6 +16,7 @@
#define STACK_SIZE (256 + CONFIG_TEST_EXTRA_STACKSIZE)
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static char tp1[8];
static int tp2 = 100;
@ -44,9 +45,9 @@ static void thread_entry_delay(void *p1, void *p2, void *p3)
/*test cases*/
void test_threads_spawn_params(void)
{
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry_params, (void *)tp1, (void *)tp2, (void *)tp3,
0, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry_params, (void *)tp1,
(void *)tp2, (void *)tp3, 0, 0, 0);
k_sleep(100);
k_thread_abort(tid);
@ -56,9 +57,9 @@ void test_threads_spawn_priority(void)
{
/* spawn thread with higher priority */
spawn_prio = k_thread_priority_get(k_current_get()) - 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry_priority, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry_priority, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_sleep(100);
k_thread_abort(tid);
}
@ -67,9 +68,9 @@ void test_threads_spawn_delay(void)
{
/* spawn thread with higher priority */
tp2 = 10;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry_delay, NULL, NULL, NULL,
0, 0, 120);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry_delay, NULL, NULL, NULL,
0, 0, 120);
/* 100 < 120 ensure spawn thread not start */
k_sleep(100);
/* checkpoint: check spawn thread not execute */

View file

@ -14,6 +14,7 @@
#define STACK_SIZE (256 + CONFIG_TEST_EXTRA_STACKSIZE)
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static int last_prio;
static void thread_entry(void *p1, void *p2, void *p3)
@ -29,21 +30,21 @@ static void threads_suspend_resume(int prio)
last_prio = prio;
k_thread_priority_set(k_current_get(), last_prio);
/* spawn thread with lower priority */
int spawn_prio = last_prio + 1;
/* create thread with lower priority */
int create_prio = last_prio + 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
create_prio, 0, 0);
/* checkpoint: suspend current thread */
k_thread_suspend(tid);
k_sleep(100);
/* checkpoint: spawned thread shouldn't be executed after suspend */
zassert_false(last_prio == spawn_prio, NULL);
/* checkpoint: created thread shouldn't be executed after suspend */
zassert_false(last_prio == create_prio, NULL);
k_thread_resume(tid);
k_sleep(100);
/* checkpoint: spawned thread should be executed after resume */
zassert_true(last_prio == spawn_prio, NULL);
/* checkpoint: created thread should be executed after resume */
zassert_true(last_prio == create_prio, NULL);
k_thread_abort(tid);

View file

@ -56,6 +56,8 @@ K_SEM_DEFINE(end_sema, 0, 1);
/*local variables*/
static char __noinit __stack stack_coop[INIT_COOP_STACK_SIZE];
static char __noinit __stack stack_preempt[INIT_PREEMPT_STACK_SIZE];
static struct k_thread thread_coop;
static struct k_thread thread_preempt;
static u64_t t_create;
static struct thread_data{
int init_prio;
@ -72,7 +74,7 @@ static void thread_entry(void *p1, void *p2, void *p3)
u64_t t_delay = k_uptime_get() - t_create;
/**TESTPOINT: check delay start*/
zassert_true(t_delay >= expected.init_delay,
"k_thread_spawn delay start failed\n");
"k_thread_create delay start failed\n");
}
k_sem_take(&start_sema, K_FOREVER);
@ -135,17 +137,18 @@ void test_kdefine_coop_thread(void)
/**
* @ingroup t_thread_init
* @brief test preempt thread initialization via k_thread_spawn
* @brief test preempt thread initialization via k_thread_create
*/
void test_kinit_preempt_thread(void)
{
/*create preempt thread*/
k_tid_t pthread = k_thread_spawn(stack_preempt, INIT_PREEMPT_STACK_SIZE,
thread_entry, INIT_PREEMPT_P1, INIT_PREEMPT_P2, INIT_PREEMPT_P3,
INIT_PREEMPT_PRIO, INIT_PREEMPT_OPTION, INIT_PREEMPT_DELAY);
k_tid_t pthread = k_thread_create(&thread_preempt, stack_preempt,
INIT_PREEMPT_STACK_SIZE, thread_entry, INIT_PREEMPT_P1,
INIT_PREEMPT_P2, INIT_PREEMPT_P3, INIT_PREEMPT_PRIO,
INIT_PREEMPT_OPTION, INIT_PREEMPT_DELAY);
/*record time stamp of thread creation*/
t_create = k_uptime_get();
zassert_not_null(pthread, "thread spawn failed\n");
zassert_not_null(pthread, "thread creation failed\n");
expected.init_p1 = INIT_PREEMPT_P1;
expected.init_p2 = INIT_PREEMPT_P2;
@ -163,14 +166,15 @@ void test_kinit_preempt_thread(void)
/**
* @ingroup t_thread_init
* @brief test coop thread initialization via k_thread_spawn
* @brief test coop thread initialization via k_thread_create
*/
void test_kinit_coop_thread(void)
{
/*create coop thread*/
k_tid_t pthread = k_thread_spawn(stack_coop, INIT_COOP_STACK_SIZE,
thread_entry, INIT_COOP_P1, INIT_COOP_P2, INIT_COOP_P3,
INIT_COOP_PRIO, INIT_COOP_OPTION, INIT_COOP_DELAY);
k_tid_t pthread = k_thread_create(&thread_coop, stack_coop,
INIT_COOP_STACK_SIZE, thread_entry, INIT_COOP_P1,
INIT_COOP_P2, INIT_COOP_P3, INIT_COOP_PRIO,
INIT_COOP_OPTION, INIT_COOP_DELAY);
/*record time stamp of thread creation*/
t_create = k_uptime_get();
zassert_not_null(pthread, "thread spawn failed\n");

View file

@ -22,6 +22,7 @@
/*local variables*/
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static struct k_sem end_sema;
static void tIsr(void *data)
@ -68,14 +69,14 @@ void test_sched_is_preempt_thread(void)
k_sem_init(&end_sema, 0, 1);
/*create preempt thread*/
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tpreempt_ctx, NULL, NULL, NULL,
K_PRIO_PREEMPT(1), 0, 0);
k_sem_take(&end_sema, K_FOREVER);
k_thread_abort(tid);
/*create coop thread*/
tid = k_thread_spawn(tstack, STACK_SIZE,
tid = k_thread_create(&tdata, tstack, STACK_SIZE,
tcoop_ctx, NULL, NULL, NULL,
K_PRIO_COOP(1), 0, 0);
k_sem_take(&end_sema, K_FOREVER);

View file

@ -15,6 +15,7 @@
#include "test_sched.h"
static char __noinit __stack tstack[STACK_SIZE];
static struct k_thread tdata;
static int last_prio;
static void thread_entry(void *p1, void *p2, void *p3)
@ -34,9 +35,9 @@ void test_priority_cooperative(void)
/* spawn thread with higher priority */
int spawn_prio = last_prio - 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
/* checkpoint: current thread shouldn't preempted by higher thread */
zassert_true(last_prio == k_thread_priority_get(k_current_get()), NULL);
k_sleep(100);
@ -58,9 +59,9 @@ void test_priority_preemptible(void)
int spawn_prio = last_prio - 1;
k_tid_t tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
/* checkpoint: thread is preempted by higher thread */
zassert_true(last_prio == spawn_prio, NULL);
@ -68,9 +69,9 @@ void test_priority_preemptible(void)
k_thread_abort(tid);
spawn_prio = last_prio + 1;
tid = k_thread_spawn(tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
tid = k_thread_create(&tdata, tstack, STACK_SIZE,
thread_entry, NULL, NULL, NULL,
spawn_prio, 0, 0);
/* checkpoint: thread is not preempted by lower thread */
zassert_false(last_prio == spawn_prio, NULL);
k_thread_abort(tid);

View file

@ -17,6 +17,7 @@
static char __noinit __stack tstack[THREADS_NUM][STACK_SIZE];
static struct thread_data tdata[THREADS_NUM];
static struct k_thread tthread[THREADS_NUM];
static int old_prio, init_prio;
static void thread_entry(void *p1, void *p2, void *p3)
@ -54,9 +55,10 @@ static void setup_threads(void)
static void spawn_threads(int sleep_sec)
{
for (int i = 0; i < THREADS_NUM; i++) {
tdata[i].tid = k_thread_spawn(tstack[i], STACK_SIZE,
thread_entry, (void *)i, (void *)sleep_sec, NULL,
tdata[i].priority, 0, 0);
tdata[i].tid = k_thread_create(&tthread[i], tstack[i],
STACK_SIZE, thread_entry,
(void *)i, (void *)sleep_sec,
NULL, tdata[i].priority, 0, 0);
}
}

View file

@ -20,6 +20,7 @@ https://www.zephyrproject.org/doc/subsystems/power_management.html#tickless-idle
#define STACK_SIZE 512
#define NUM_THREAD 4
static char __noinit __stack tstack[NUM_THREAD][STACK_SIZE];
static struct k_thread tdata[NUM_THREAD];
/*for those not supporting tickless idle*/
#ifndef CONFIG_TICKLESS_IDLE
#define CONFIG_TICKLESS_IDLE_THRESH 20
@ -92,7 +93,7 @@ void test_tickless_slice(void)
/*create delayed threads with equal preemptive priority*/
for (int i = 0; i < NUM_THREAD; i++) {
tid[i] = k_thread_spawn(tstack[i], STACK_SIZE,
tid[i] = k_thread_create(&tdata[i], tstack[i], STACK_SIZE,
thread_tslice, NULL, NULL, NULL,
K_PRIO_PREEMPT(0), 0, SLICE_SIZE);
}

View file

@ -29,6 +29,7 @@ struct test_item {
};
static char __stack co_op_stack[STACK_SIZE];
static struct k_thread co_op_data;
static struct test_item tests[NUM_TEST_ITEMS];
@ -76,10 +77,9 @@ static void test_items_submit(void)
{
int i;
k_thread_spawn(co_op_stack, STACK_SIZE,
k_thread_create(&co_op_data, co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_work_main,
NULL, NULL,
NULL, K_PRIO_COOP(10), 0, 0);
NULL, NULL, NULL, K_PRIO_COOP(10), 0, 0);
for (i = 0; i < NUM_TEST_ITEMS; i += 2) {
TC_PRINT(" - Submitting work %d from preempt thread\n", i + 1);
@ -211,8 +211,8 @@ static int test_delayed_submit(void)
{
int i;
k_thread_spawn(co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_delayed_work_main,
k_thread_create(&co_op_data, co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_delayed_work_main,
NULL, NULL, NULL, K_PRIO_COOP(10), 0, 0);
for (i = 0; i < NUM_TEST_ITEMS; i += 2) {
@ -247,8 +247,8 @@ static int test_delayed_cancel(void)
TC_PRINT(" - Cancel delayed work from preempt thread\n");
k_delayed_work_cancel(&tests[0].work);
k_thread_spawn(co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_delayed_work_cancel_main,
k_thread_create(&co_op_data, co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_delayed_work_cancel_main,
NULL, NULL, NULL, K_PRIO_COOP(10), 0, 0);
TC_PRINT(" - Waiting for work to finish\n");
@ -315,8 +315,8 @@ static int test_delayed_resubmit_fiber(void)
tests[0].key = 1;
k_delayed_work_init(&tests[0].work, delayed_work_handler);
k_thread_spawn(co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_delayed_work_resubmit,
k_thread_create(&co_op_data, co_op_stack, STACK_SIZE,
(k_thread_entry_t)coop_delayed_work_resubmit,
NULL, NULL, NULL, K_PRIO_COOP(10), 0, 0);
TC_PRINT(" - Waiting for work to finish\n");

View file

@ -906,10 +906,11 @@ static void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}

View file

@ -680,10 +680,11 @@ void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}

View file

@ -170,6 +170,7 @@ static void test_3_thread(void *arg1, void *arg2, void *arg3)
static void net_buf_test_3(void)
{
static char __stack test_3_thread_stack[1024];
static struct k_thread test_3_thread_data;
struct net_buf *frag, *head;
struct k_fifo fifo;
struct k_sem sema;
@ -188,9 +189,10 @@ static void net_buf_test_3(void)
k_fifo_init(&fifo);
k_sem_init(&sema, 0, UINT_MAX);
k_thread_spawn(test_3_thread_stack, sizeof(test_3_thread_stack),
(k_thread_entry_t) test_3_thread, &fifo, &sema, NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&test_3_thread_data, test_3_thread_stack,
sizeof(test_3_thread_stack),
(k_thread_entry_t) test_3_thread, &fifo, &sema, NULL,
K_PRIO_COOP(7), 0, 0);
zassert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
"Timeout while waiting for semaphore");

View file

@ -905,6 +905,7 @@ static bool net_ctx_recv_v4_reconfig(void)
#define STACKSIZE 1024
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
static void recv_cb_timeout(struct net_context *context,
struct net_pkt *pkt,
@ -940,18 +941,18 @@ void timeout_thread(struct net_context *ctx, sa_family_t *family)
static void start_timeout_v6_thread(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)timeout_thread,
udp_v6_ctx, INT_TO_POINTER(AF_INET6), NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)timeout_thread,
udp_v6_ctx, INT_TO_POINTER(AF_INET6), NULL,
K_PRIO_COOP(7), 0, 0);
}
static void start_timeout_v4_thread(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)timeout_thread,
udp_v4_ctx, INT_TO_POINTER(AF_INET), NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)timeout_thread,
udp_v4_ctx, INT_TO_POINTER(AF_INET), NULL,
K_PRIO_COOP(7), 0, 0);
}
static bool net_ctx_recv_v6_timeout(void)

View file

@ -546,10 +546,11 @@ void main_thread(void)
#define STACKSIZE 3000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
}

View file

@ -120,10 +120,11 @@ void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
}

View file

@ -533,10 +533,11 @@ static void main_thread(void)
#define STACKSIZE 8000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
}

View file

@ -444,10 +444,11 @@ void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}

View file

@ -22,6 +22,7 @@ static u32_t event2throw;
static u32_t throw_times;
static int throw_sleep;
static char __noinit __stack thrower_stack[512];
static struct k_thread thrower_thread_data;
static struct k_sem thrower_lock;
/* Receiver infra */
@ -205,9 +206,10 @@ static void initialize_event_tests(void)
net_mgmt_init_event_callback(&rx_cb, receiver_cb, TEST_MGMT_EVENT);
k_thread_spawn(thrower_stack, sizeof(thrower_stack),
(k_thread_entry_t)thrower_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
k_thread_create(&thrower_thread_data, thrower_stack,
sizeof(thrower_stack),
(k_thread_entry_t)thrower_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}
static int test_core_event(u32_t event, bool (*func)(void))

View file

@ -370,10 +370,11 @@ void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread, NULL, NULL, NULL,
K_PRIO_COOP(7), 0, 0);
}

View file

@ -592,10 +592,11 @@ void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}

View file

@ -753,10 +753,11 @@ void main_thread(void)
#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;
void main(void)
{
k_thread_spawn(&thread_stack[0], STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
k_thread_create(&thread_data, thread_stack, STACKSIZE,
(k_thread_entry_t)main_thread,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}

View file

@ -7,7 +7,8 @@
#include "soc_watch_logger.h"
#define STSIZE 512
char __stack soc_watch_event_logger_stack[1][STSIZE];
static char __stack __noinit soc_watch_event_logger_stack[STSIZE];
static struct k_thread soc_watch_event_logger_data;
/**
* @brief soc_watch data collector thread
@ -91,7 +92,8 @@ void soc_watch_logger_thread_start(void)
{
PRINTF("\x1b[2J\x1b[15;1H");
k_thread_spawn(&soc_watch_event_logger_stack[0][0], STSIZE,
k_thread_create(&soc_watch_event_logger_data,
soc_watch_event_logger_stack, STSIZE,
(k_thread_entry_t) soc_watch_data_collector, 0, 0, 0,
6, 0, 0);
}

View file

@ -63,15 +63,15 @@ void threadB(void *dummy1, void *dummy2, void *dummy3)
}
char __noinit __stack threadB_stack_area[STACKSIZE];
static struct k_thread threadB_data;
/* threadA is a static thread that is spawned automatically */
void threadA(void *dummy1, void *dummy2, void *dummy3)
{
/* spawn threadB */
k_thread_spawn(threadB_stack_area, STACKSIZE, threadB, NULL, NULL, NULL,
PRIORITY, 0, K_NO_WAIT);
k_thread_create(&threadB_data, threadB_stack_area, STACKSIZE, threadB,
NULL, NULL, NULL, PRIORITY, 0, K_NO_WAIT);
/* invoke routine to ping-pong hello messages with threadB */
helloLoop(__func__, &threadA_sem, &threadB_sem);

View file

@ -128,8 +128,9 @@ out:
#if CONFIG_ZTEST_STACKSIZE & (STACK_ALIGN - 1)
#error "CONFIG_ZTEST_STACKSIZE must be a multiple of the stack alignment"
#endif
static char __stack thread_stack[CONFIG_ZTEST_STACKSIZE +
CONFIG_TEST_EXTRA_STACKSIZE];
static struct k_thread ztest_thread;
static char __stack __noinit thread_stack[CONFIG_ZTEST_STACKSIZE +
CONFIG_TEST_EXTRA_STACKSIZE];
static int test_result;
static struct k_sem test_end_signal;
@ -165,7 +166,7 @@ static int run_test(struct unit_test *test)
int ret = TC_PASS;
TC_START(test->name);
k_thread_spawn(&thread_stack[0], sizeof(thread_stack),
k_thread_create(&ztest_thread, thread_stack, sizeof(thread_stack),
(k_thread_entry_t) test_cb, (struct unit_test *)test,
NULL, NULL, -1, 0, 0);