Author Topic: when to use task_create?  (Read 267 times)

names_are_hard

  • Contributor
  • Freshman
  • *****
  • Posts: 71
  • 200D idiot
when to use task_create?
« 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?

srsa

  • New to the forum
  • *
  • Posts: 14
Re: when to use task_create?
« Reply #1 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).

names_are_hard

  • Contributor
  • Freshman
  • *****
  • Posts: 71
  • 200D idiot
Re: when to use task_create?
« Reply #2 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.