当前位置:网站首页>Zephyr learning notes 1, threads

Zephyr learning notes 1, threads

2022-07-04 07:22:00 mayiQX

Starting Today Zephyr Study , Target board nrf9160.

Chapter one : How to create threads (thread).

1.K_THREAD_DEFINE() API

K_THREAD_DEFINE(name, stack_size, entry, p1, p2, p3, prio, options, delay)

Parameters:
name – Name of the thread.

stack_size – Stack size in bytes.

entry – Thread entry function.

p1 – 1st entry point parameter.

p2 – 2nd entry point parameter.

p3 – 3rd entry point parameter.

prio – Thread priority.

options – Thread options.

delay – Scheduling delay (in milliseconds), zero for no delay.

2.Thread Priorities are divided into collaborative and preemptive

Collaborative <0, Preemptive \geq0.

3. Create and use thread

#define STACKSIZE 1024

#define THREAD0_PRIORITY 7
#define THREAD1_PRIORITY 7

void thread0(void)
{

}

void thread1(void)
{

}

/* Define and initialize the two threads */
K_THREAD_DEFINE(thread0_id, STACKSIZE, thread0, NULL, NULL, NULL,
		THREAD0_PRIORITY, 0, 0);
K_THREAD_DEFINE(thread1_id, STACKSIZE, thread1, NULL, NULL, NULL,
		THREAD1_PRIORITY, 0, 0);

原网站

版权声明
本文为[mayiQX]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207040715383244.html