when to use task_create?

Started by names_are_hard, July 07, 2019, 06:09:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

names_are_hard

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?

srsa

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

names_are_hard

Thanks, that's mostly how I guessed (hadn't considered the priority).  I think I know the right way to do what I want.