supervisor: tick: Rewrite without atomics
This commit is contained in:
parent
568636d562
commit
70719597ab
@ -24,14 +24,12 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdatomic.h>
|
|
||||||
|
|
||||||
#include "supervisor/shared/tick.h"
|
#include "supervisor/shared/tick.h"
|
||||||
#include "supervisor/filesystem.h"
|
#include "supervisor/filesystem.h"
|
||||||
#include "supervisor/shared/autoreload.h"
|
#include "supervisor/shared/autoreload.h"
|
||||||
|
|
||||||
static atomic_bool tick_up;
|
|
||||||
static volatile uint64_t ticks_ms;
|
static volatile uint64_t ticks_ms;
|
||||||
|
static volatile uint32_t background_ticks_ms32;
|
||||||
|
|
||||||
#if CIRCUITPY_GAMEPAD
|
#if CIRCUITPY_GAMEPAD
|
||||||
#include "shared-module/gamepad/__init__.h"
|
#include "shared-module/gamepad/__init__.h"
|
||||||
@ -47,8 +45,6 @@ void supervisor_tick(void) {
|
|||||||
|
|
||||||
ticks_ms ++;
|
ticks_ms ++;
|
||||||
|
|
||||||
atomic_store(&tick_up, true);
|
|
||||||
|
|
||||||
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
|
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
|
||||||
filesystem_tick();
|
filesystem_tick();
|
||||||
#endif
|
#endif
|
||||||
@ -82,7 +78,14 @@ uint32_t supervisor_ticks_ms32() {
|
|||||||
extern void run_background_tasks(void);
|
extern void run_background_tasks(void);
|
||||||
|
|
||||||
void supervisor_run_background_tasks_if_tick() {
|
void supervisor_run_background_tasks_if_tick() {
|
||||||
if (atomic_exchange(&tick_up, false)) {
|
uint32_t now32 = ticks_ms;
|
||||||
run_background_tasks();
|
|
||||||
|
if (now32 == background_ticks_ms32) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
background_ticks_ms32 = now32;
|
||||||
|
|
||||||
|
run_background_tasks();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#define __INCLUDED_SUPERVISOR_TICK_H
|
#define __INCLUDED_SUPERVISOR_TICK_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdatomic.h>
|
|
||||||
|
|
||||||
extern void supervisor_tick(void);
|
extern void supervisor_tick(void);
|
||||||
extern uint32_t supervisor_ticks_ms32(void);
|
extern uint32_t supervisor_ticks_ms32(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user