summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/mpconfig.h6
-rw-r--r--py/scheduler.c1
2 files changed, 7 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 4445e9aee2..7337994a5e 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -550,6 +550,12 @@
#define MICROPY_VM_HOOK_RETURN
#endif
+// Hook for mp_sched_schedule when a function gets scheduled on sched_queue
+// (this macro executes within an atomic section)
+#ifndef MICROPY_SCHED_HOOK_SCHEDULED
+#define MICROPY_SCHED_HOOK_SCHEDULED
+#endif
+
// Whether to include the garbage collector
#ifndef MICROPY_ENABLE_GC
#define MICROPY_ENABLE_GC (0)
diff --git a/py/scheduler.c b/py/scheduler.c
index 9ff930007e..947510c68b 100644
--- a/py/scheduler.c
+++ b/py/scheduler.c
@@ -134,6 +134,7 @@ bool MICROPY_WRAP_MP_SCHED_SCHEDULE(mp_sched_schedule)(mp_obj_t function, mp_obj
uint8_t iput = IDX_MASK(MP_STATE_VM(sched_idx) + MP_STATE_VM(sched_len)++);
MP_STATE_VM(sched_queue)[iput].func = function;
MP_STATE_VM(sched_queue)[iput].arg = arg;
+ MICROPY_SCHED_HOOK_SCHEDULED;
ret = true;
} else {
// schedule queue is full