Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

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

  1. #1
    Junior Member
    Join Date
    Jan 2019
    Posts
    10

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

    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.

  2. #2
    Junior Member
    Join Date
    Jan 2019
    Posts
    10
    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.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,323
    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.

  4. #4
    Junior Member
    Join Date
    Jan 2019
    Posts
    10
    Quote Originally Posted by PaulStoffregen View Post
    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!

  5. #5
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    961
    Quote Originally Posted by Paul_M View Post
    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.

  6. #6
    Junior Member
    Join Date
    Jan 2019
    Posts
    10
    Quote Originally Posted by duff View Post
    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.

  7. #7

  8. #8
    Junior Member
    Join Date
    Jan 2019
    Posts
    10
    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!

  9. #9
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,137
    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

  10. #10
    Junior Member
    Join Date
    Jan 2019
    Posts
    10
    Quote Originally Posted by el_supremo View Post
    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.

  11. #11
    Junior Member
    Join Date
    Jan 2019
    Posts
    10
    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 by Paul_M; 03-27-2019 at 03:47 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •