How to have true multithreading on LC / Zilch library is not working?

Status
Not open for further replies.

Paul_M

Member
Hello -

I am in love with my Teensy 3.6 + TeensyThreads implementation but have good cause to use my Teensy LCs for less intensive purposes though needing true multitasking.

TeensyThreads doesn't support LC. FreeRTOS isn't working or compiling.

The Zilch library is supposed to work on LC (see this thread), but I get this error when running the example:

libraries\Zilch-master\zilch.cpp:542:23: error: invalid conversion from 'volatile stack_frame_t*' to 'stack_frame_t*' [-fpermissive]

task_swap( p1, p2 );

^

Can anybody instruct on how I can get this to work?

Yes, before you ask, I truly need multithreading.
 
See as though the Teensy 3.2 has TWICE the power consumption as the M0-based Teensy LC, I REALLY would like be to able to use my Teensy LCs that I have bought.

Has anyone got been able to get any context-switch multithreading working on Teensy LC? Either through TeensyThreads, ChibiOS, FreeRTOS, Zilch, or anything else?

I know it is possible. Therefore there is no reason there shouldn't be a readily available option.

I am a huge fan of Teensy products but the LC supporting multithreading would be a true game-changer for me. I will buy many more if someone can show me how this is possible.
 
Is this the code you're trying to use?

https://github.com/duff2013/Zilch

Asking 'cause I don't see any mention that it works on LC.

Paul, thank you for your reply, and know that I am a HUGE supporter of your products.

Please see the "zilch.h" file which states at the very top:
* Lightweight Scheduler Library for Teensy LC/3.x

Also see this thread which discusses it being used on Teensy LC, but alas, none of the examples compile.

Here is a full output when I try to compile the "simple" example for LC:
Arduino\libraries\Zilch-master\zilch.cpp:542:23: error: invalid conversion from 'volatile stack_frame_t*' to 'stack_frame_t*' [-fpermissive]

task_swap( p1, p2 );


^

\Arduino\libraries\Zilch-master\zilch.cpp:390:6: note: initializing argument 1 of 'void task_swap(stack_frame_t*, stack_frame_t*)'

void task_swap( stack_frame_t *prevframe, stack_frame_t *nextframe ) {

^

Arduino\libraries\Zilch-master\zilch.cpp:542:23: error: invalid conversion from 'volatile stack_frame_t*' to 'stack_frame_t*' [-fpermissive]

task_swap( p1, p2 );


^

Arduino\libraries\Zilch-master\zilch.cpp:390:6: note: initializing argument 2 of 'void task_swap(stack_frame_t*, stack_frame_t*)'

void task_swap( stack_frame_t *prevframe, stack_frame_t *nextframe ) {

^

Arduino\libraries\Zilch-master\zilch.cpp: In function 'TaskState task_stop(task_func_t)':

\Arduino\libraries\Zilch-master\zilch.cpp:599:28: warning: unused variable 'p' [-Wunused-variable]

stack_frame_t *p = ( stack_frame_t * )start->block;

^

Arduino\libraries\Zilch-master\zilch.cpp:602:1: warning: no return statement in function returning non-void [-Wreturn-type]

}

^

Error compiling for board Teensy LC.

Thank you for your help!
 
Hello -

I am in love with my Teensy 3.6 + TeensyThreads implementation but have good cause to use my Teensy LCs for less intensive purposes though needing true multitasking.

TeensyThreads doesn't support LC. FreeRTOS isn't working or compiling.

The Zilch library is supposed to work on LC (see this thread), but I get this error when running the example:

libraries\Zilch-master\zilch.cpp:542:23: error: invalid conversion from 'volatile stack_frame_t*' to 'stack_frame_t*' [-fpermissive]

task_swap( p1, p2 );

^

Can anybody instruct on how I can get this to work?

Yes, before you ask, I truly need multithreading.

The latest version dose not currently work with the LC, it did before I rewrote it. It's on my todo list so you bringing it up might help me speed up that. I'm currently got a lot of irons in the fire so when exactly I can't say. Maybe I'll see if I can get it working this weekend.
 
The latest version dose not currently work with the LC, it did before I rewrote it. It's on my todo list so you bringing it up might help me speed up that. I'm currently got a lot of irons in the fire so when exactly I can't say. Maybe I'll see if I can get it working this weekend.
Sir, thank you so much for the response.

Can you provide a link to whatever old version which did work on LC, prior to rewrite?

As long as it enabled context-switching multithreading on LC, it "works" for my purposes, no matter what improvements you made in the rewrite :)

Again, thank you.
 

Thank you. While that version DOES compile (so, we're making progress!), it unfortunately hangs on any call to task.create() on Teensy LC.

E.g., the example "Simple_Task" and "Pause_Task" do not show any serial output, nor does the main loop() ever execute, because "task.create(task1, 5000, 0);" hangs execution.

I did verify it hangs by outputting serial before this line, and using the LED_BUILTIN, to see that nothing happens after task.create.

Perhaps you have a quick intuitive idea on why task.create() is hanging? I even increased the stack size to 5000 bytes in the example file, and it would still hang and not work.

Thank you in advance for your much-appreciated help!
 
FWIW: I've just installed Zilch v0.3 and tried the Simple_Task example on a Teensy LC. It seems to work. I get this sort of output:
Code:
loop
task1
task2
task3
task4
task5
loop
task1
task2
task3
task4
task5
task1
task2
task3
task4
task5

I'm using Arduino 1.8.9 and TD 1.46 beta 10.

Pete
 
FWIW: I've just installed Zilch v0.3 and tried the Simple_Task example on a Teensy LC. It seems to work. I get this sort of output:
Code:
loop
task1
task2
task3
task4
task5
loop
task1
task2
task3
task4
task5
task1
task2
task3
task4
task5

I'm using Arduino 1.8.9 and TD 1.46 beta 10.

Pete

Fascinating. Thank you for sharing. I am using TD 1.4.5 and Arduino 1.8.5 to reproduce the task.create() hang with this old LC-compatible version of Zilch.

I will reproduce once more then upgrade both IDE and TD, and see if that makes a change.
 
Problem identified.

I had the optimization set to "Fast".

I realized this, and immediately had a wishful-thought that this was somehow corrupting the low-level operations within the Zilch library.

I restored the optimization mode to "Smallest Code" and viola! Zilch 0.3 works on Teensy LC using the Simple_Task example. I can't wait to structure my code with it, profile, and see if I can get satisfactory results in my own specific application. But it works.

Out of curiosity, I tested all three "Fast" optimization modes (Fast, Faster, and Fastest). They all elicited an undesirable interaction with the Zilch library and caused it to not work.

Good to know. Thanks everyone!
 
Last edited:
Status
Not open for further replies.
Back
Top