diff options
| author | Jeff Epler <jepler@gmail.com> | 2019-11-20 10:15:11 -0600 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2019-11-20 14:37:13 -0600 |
| commit | 70719597ab7b3785a6641b08ef3cb82d9b6b459b (patch) | |
| tree | 6425b647aef4a8b0c988b03820bf60e4850e2e0b /supervisor | |
| parent | 568636d562b4c64d0095ff2ac921b79eb69e520d (diff) | |
supervisor: tick: Rewrite without atomics
Diffstat (limited to 'supervisor')
| -rw-r--r-- | supervisor/shared/tick.c | 17 | ||||
| -rw-r--r-- | supervisor/shared/tick.h | 1 |
2 files changed, 10 insertions, 8 deletions
diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 7dc5a52d3..0be323082 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -24,14 +24,12 @@ * THE SOFTWARE. */ -#include <stdatomic.h> - #include "supervisor/shared/tick.h" #include "supervisor/filesystem.h" #include "supervisor/shared/autoreload.h" -static atomic_bool tick_up; static volatile uint64_t ticks_ms; +static volatile uint32_t background_ticks_ms32; #if CIRCUITPY_GAMEPAD #include "shared-module/gamepad/__init__.h" @@ -47,8 +45,6 @@ void supervisor_tick(void) { ticks_ms ++; - atomic_store(&tick_up, true); - #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif @@ -82,7 +78,14 @@ uint32_t supervisor_ticks_ms32() { extern void run_background_tasks(void); void supervisor_run_background_tasks_if_tick() { - if (atomic_exchange(&tick_up, false)) { - run_background_tasks(); + uint32_t now32 = ticks_ms; + + if (now32 == background_ticks_ms32) { + return; } + background_ticks_ms32 = now32; + + run_background_tasks(); +} + } diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index b66273449..eb2af29ca 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -28,7 +28,6 @@ #define __INCLUDED_SUPERVISOR_TICK_H #include <stdint.h> -#include <stdatomic.h> extern void supervisor_tick(void); extern uint32_t supervisor_ticks_ms32(void); |
