From f95b42fdbb4987ac1fe7cbc4297ffc0961c283da Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Thu, 21 Nov 2019 18:06:18 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"=F0=9F=90=9B=20Fix=20race=20and=20an?= =?UTF-8?q?=20abandoned=20mutex=20(#180)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a02cefcfe9581b8ebcc13a31ade554fee192b2bd. --- src/display/lv_misc/lv_task.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/display/lv_misc/lv_task.c b/src/display/lv_misc/lv_task.c index 3d7514bba..c41695a6b 100644 --- a/src/display/lv_misc/lv_task.c +++ b/src/display/lv_misc/lv_task.c @@ -63,27 +63,17 @@ void lv_task_init(void) LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) { LV_LOG_TRACE("lv_task_handler started"); - bool task_run = __atomic_load_n(&lv_task_run, __ATOMIC_ACQUIRE); - - if(task_run == false) - { - LV_LOG_TRACE("lv_task_handler bailed early, task run false"); - return; - } /*Avoid concurrent running of the task handler*/ static bool task_handler_mutex = false; - - bool expected = false; - bool toSet = true; - bool alreadyTaken = __atomic_compare_exchange(&task_handler_mutex, &expected, &toSet,/* weak*/ false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE); - - if (alreadyTaken) return; + if(task_handler_mutex) return; + task_handler_mutex = true; static uint32_t idle_period_start = 0; static uint32_t handler_start = 0; static uint32_t busy_time = 0; + if(lv_task_run == false) return; handler_start = lv_tick_get(); @@ -158,7 +148,7 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) } - __atomic_store_n(&task_handler_mutex, false, __ATOMIC_RELEASE); + task_handler_mutex = false; /*Release the mutex*/ LV_LOG_TRACE("lv_task_handler ready"); } @@ -294,7 +284,7 @@ void lv_task_reset(lv_task_t * lv_task_p) */ void lv_task_enable(bool en) { - __atomic_store_n(&lv_task_run, en, __ATOMIC_RELAXED); + lv_task_run = en; } /**