From 3440598118f1e4b7ef3f59b0f24046216a03c3db Mon Sep 17 00:00:00 2001 From: erlingrj Date: Tue, 23 May 2023 13:54:48 -0700 Subject: [PATCH 1/2] Fixes on thread creation and deletion --- core/platform/lf_zephyr_support.c | 8 +++++++- include/core/platform/lf_zephyr_support.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/platform/lf_zephyr_support.c b/core/platform/lf_zephyr_support.c index 12bb8a1ca..ca7654b8c 100644 --- a/core/platform/lf_zephyr_support.c +++ b/core/platform/lf_zephyr_support.c @@ -414,9 +414,15 @@ int lf_thread_create(lf_thread_t* thread, void *(*lf_thread) (void *), void* arg (void *) lf_thread, arguments, NULL, _LF_THREAD_PRIORITY, 0, K_NO_WAIT); + + // Pass the pointer to the k_thread struct out. This is needed + // to join on the thread later + *thread = &threads[tid]; + + // Increment the tid counter so that next call to `lf_thread_create` + // uses the next available k_thread struct and stack tid++; - *thread = my_tid; k_mutex_unlock(&thread_mutex); diff --git a/include/core/platform/lf_zephyr_support.h b/include/core/platform/lf_zephyr_support.h index ea1c0426a..0e1e0b6ea 100644 --- a/include/core/platform/lf_zephyr_support.h +++ b/include/core/platform/lf_zephyr_support.h @@ -50,7 +50,7 @@ typedef struct { lf_mutex_t* mutex; struct k_condvar condition; } lf_cond_t; -typedef k_tid_t lf_thread_t; +typedef struct k_thread* lf_thread_t; extern lf_mutex_t mutex; extern lf_cond_t event_q_changed; From 37c94ec64bc79a04f995082a8d0aa47bda9e366a Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Thu, 25 May 2023 21:55:50 -0700 Subject: [PATCH 2/2] Apply suggestions from code review --- core/platform/lf_zephyr_support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/platform/lf_zephyr_support.c b/core/platform/lf_zephyr_support.c index ca7654b8c..9dbf40c04 100644 --- a/core/platform/lf_zephyr_support.c +++ b/core/platform/lf_zephyr_support.c @@ -416,11 +416,11 @@ int lf_thread_create(lf_thread_t* thread, void *(*lf_thread) (void *), void* arg // Pass the pointer to the k_thread struct out. This is needed - // to join on the thread later + // to join on the thread later. *thread = &threads[tid]; // Increment the tid counter so that next call to `lf_thread_create` - // uses the next available k_thread struct and stack + // uses the next available k_thread struct and stack. tid++;