This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 54bcf3afdd5f1c7a10dbb425f0e31702937658ff
Author: raiden00pl <[email protected]>
AuthorDate: Wed May 17 12:11:22 2023 +0200

    examples/foc/foc_thr: fix mutex logic
---
 examples/foc/foc_thr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/foc/foc_thr.c b/examples/foc/foc_thr.c
index de5d580e5..83b39ce5a 100644
--- a/examples/foc/foc_thr.c
+++ b/examples/foc/foc_thr.c
@@ -256,14 +256,14 @@ bool foc_threads_terminated(void)
 {
   bool ret = false;
 
-  pthread_mutex_unlock(&g_cntr_lock);
+  pthread_mutex_lock(&g_cntr_lock);
 
   if (g_foc_thr == 0)
     {
       ret = true;
     }
 
-  pthread_mutex_lock(&g_cntr_lock);
+  pthread_mutex_unlock(&g_cntr_lock);
 
   return ret;
 }
@@ -276,9 +276,9 @@ uint32_t foc_threads_get(void)
 {
   uint32_t ret = 0;
 
-  pthread_mutex_unlock(&g_cntr_lock);
-  ret = g_foc_thr;
   pthread_mutex_lock(&g_cntr_lock);
+  ret = g_foc_thr;
+  pthread_mutex_unlock(&g_cntr_lock);
 
   return ret;
 }

Reply via email to