Preemption in esp alarm code
Opened this issue · 1 comments
jonsmirl commented
https://github.com/MitchBradley/cforth/blob/master/src/app/esp32/extend.c#L84
That can run with the forth VM in any state. Is switching stacks all it takes to preempt the VM and preserve state? sp, rp, tos, ip are on the ESP32 stack.
If I wrap my programmatic execute_word() calls like this, does the wrapping then protect the interactive session from them? I guess I never needed this because my programmatic execute_word() calls always leave the stack clean. Is this needed if the calls always leave a clean stack?
switch_stacks(&my_stacks_save, &my_stacks, callback_up);
spush(cmd, callback_up);
spush(strlen(cmd), callback_up);
execute_word("evaluate", callback_up);
switch_stacks(NULL, &my_stacks_save, callback_up);
MitchBradley commented
I think that if the way it works but it been a few years since I thought about it in detail