Page 1 of 1

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

Posted: Tue Oct 31, 2017 8:44 pm
by jickster
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?

Re: native & viper - how to interrupt loop execution

Posted: Mon Nov 06, 2017 4:30 pm
by jickster
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()