cforth icon indicating copy to clipboard operation
cforth copied to clipboard

Preemption in esp alarm code

Open jonsmirl opened this issue 1 year ago • 1 comments

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);

jonsmirl avatar Mar 26 '23 01:03 jonsmirl

I think that if the way it works but it been a few years since I thought about it in detail

MitchBradley avatar Mar 26 '23 03:03 MitchBradley