Update repo

This commit is contained in:
hangpersonal committed 2026-10-19 23:09:38 -07:00
1 parent 42d54dc132
commit 6c33721f5e
19 files changed
+491 -1

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
#include <zephyr/kernel.h>
#define THREAD_A_STACK_SIZE 512
#define THREAD_A_PRIORITY 2
#define THREAD_B_STACK_SIZE 512
#define THREAD_B_PRIORITY 10
K_THREAD_STACK_DEFINE(thread_a_stack, THREAD_A_STACK_SIZE);
struct k_thread thread_a_data;
k_tid_t thread_a_id;
void thread_a_entry(void *p1, void *p2, void *p3) {
printk("Thread_A: running, about to suspend\n");
k_thread_suspend(k_current_get());
printk("Thread_A: resumed, exiting\n");
}
void thread_b_entry(void *p1, void *p2, void *p3) {
printk("Thread_B: running, sleeping for 500ms\n");
k_sleep(K_MSEC(500));
printk("Thread_B: woke up after 500ms, resuming Thread_A\n");
k_thread_resume(thread_a_id);
}
int main(void) {
thread_a_id =
k_thread_create(&thread_a_data,
thread_a_stack,
K_THREAD_STACK_SIZEOF(thread_a_stack),
thread_a_entry, NULL, NULL, NULL,
THREAD_A_PRIORITY, 0, K_NO_WAIT);
ARG_UNUSED(thread_a_id);
return 0;
}
K_THREAD_DEFINE(thread_b_id, THREAD_B_STACK_SIZE,
thread_b_entry, NULL, NULL, NULL,
THREAD_B_PRIORITY, 0, 0);