Skip to content

Commit 8c4a9f6

Browse files
committed
supervisor: tick: only run background tasks once per tick
1 parent 1474fcc commit 8c4a9f6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

supervisor/shared/tick.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
5252
#define WATCHDOG_EXCEPTION_CHECK() 0
5353
#endif
5454

55+
static background_callback_t callback;
56+
57+
extern void run_background_tasks(void);
58+
59+
void background_task_tick(void *unused) {
60+
run_background_tasks();
61+
}
62+
5563
void supervisor_tick(void) {
5664
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
5765
filesystem_tick();
@@ -69,6 +77,7 @@ void supervisor_tick(void) {
6977
#endif
7078
}
7179
#endif
80+
background_callback_add(&callback, background_task_tick, NULL);
7281
}
7382

7483
uint64_t supervisor_ticks_ms64() {
@@ -84,11 +93,9 @@ uint32_t supervisor_ticks_ms32() {
8493
return supervisor_ticks_ms64();
8594
}
8695

87-
extern void run_background_tasks(void);
8896

8997
void PLACE_IN_ITCM(supervisor_run_background_tasks_if_tick)() {
9098
background_callback_run_all();
91-
run_background_tasks();
9299
}
93100

94101
void mp_hal_delay_ms(mp_uint_t delay) {

0 commit comments

Comments
 (0)