[SOLVED]native & viper - how to interrupt loop execution

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

[SOLVED]native & viper - how to interrupt loop execution

Post by jickster » Tue Oct 31, 2017 8:44 pm

I have a cooperative multitasking RTOS and I'm integrating micropython into this environment.

If my users create .py scripts with for- or while-loops, I have to be able to RTOS.yield() to other RTOS tasks after a certain amount of time.
If I configure uPython to only use bytecode, this is trivial: I modify the macro

Code: Select all

DISPATCH()
inside vm.c to check for elapsed time and call RTOS.yield().

However, if native/viper code is generated, there's no way for me to insert a custom piece of code at the end of the for-loop, correct?
Last edited by jickster on Mon Nov 06, 2017 4:30 pm, edited 1 time in total.

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: native & viper - how to interrupt loop execution

Post by jickster » Mon Nov 06, 2017 4:30 pm

Obviously the only way to do this is to setup an OS timer that asynchronously interrupts micropython execution and enables me to execute RTOS.yield()

Post Reply