examples/foc/foc_thr: fix mutex logic

This commit is contained in:
raiden00pl 2023-05-17 12:11:22 +02:00 committed by Xiang Xiao
parent e15db0c21b
commit 54bcf3afdd

View File

@ -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;
}