mp_sched_schedule_node vs mp_sched_schedule #9855
-
What is the difference in use? mp_sched_schedule_node looks like it prevents reentering to an IRQ user function and looks safer for the end user. May anybody add some comments to https://github.com/micropython/micropython/blob/master/py/scheduler.c? P.S. This question applies to ESP32: Add Quadrature Encoder and Pulse Counter classes. #8766 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In summary - Importantly there are only a fixed number of pre-allocated slots for
It's really just about the use case -- before
mp_sched_schedule_node is newer. There might be some cases of mp_sched_schedule that could now be mp_sched_schedule_node, but for the most part mp_sched_schedule will be used whenever C code needs to invoke a user callback provided in Python. |
Beta Was this translation helpful? Give feedback.
In summary -
mp_sched_schedule
is for running a Python function in the scheduler. The most common use case is to execute a soft IRQ handler.mp_sched_schedule_node
is for running a C function, typically some sort of background task (bluetooth, networking, usb, etc).Importantly there are only a fixed number of pre-allocated slots for
mp_sched_schedule
, whereas withmp_sched_schedule_node
the calling code provides the linked list node.It's really just about the use case -- before
mp_sched_schedule_node
, background tasks implemented in C had to create a "fake" Python functio…