Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: names_are_hard on July 07, 2019, 06:09:44 PM

Title: when to use task_create?
Post by: names_are_hard on July 07, 2019, 06:09:44 PM
I'm doing some work on logging in my 200D port and I'm confused by the advantages of task_create.  Can someone explain the difference between these two examples?

    msleep(1000);
    do_stuff();

and

    msleep(1000);
    task_create("do_stuff", 0x1e, 0x1000, do_stuff, 0 );   

Is the benefit on the second case related to blocking, because tasks go in a queue?  Is that all there is?
Title: Re: when to use task_create?
Post by: srsa on July 07, 2019, 06:50:08 PM
If you start do_stuff() the first way, it will obviously execute in the same task.

If you launch it as a new task, it will run independently, in parallel. Also, you get to specify the task priority (0x1e), and the amount of stack space (0x1000).
Title: Re: when to use task_create?
Post by: names_are_hard on July 07, 2019, 07:39:24 PM
Thanks, that's mostly how I guessed (hadn't considered the priority).  I think I know the right way to do what I want.