MQX question: _task_create with the same task multiple times?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX question: _task_create with the same task multiple times?

1,530 Views
jbaker1
Contributor I

I am developing with MQX RTOS using MQX 5.0, and I have a question regarding the creation of tasks.

I've gotten to the point that can start tasks by filling out a TASK_TEMPLATE_STRUCT MQX_template_list[] array with the following:

{ Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice }

followed by officially creating the task with the following call:

_task_create(0, Task Index, param); // send param to the task to control which data the task works on.

I've found that it is possible to call task_create with the same task index multiple times. This is desirable for the application I'm working on... and it the application seems to run OK so far. 

Is there any downside to creating tasks this way? I've put code around this to limit the creation of "duplicate tasks" to 20.

The one obvious thing I can think of is that I need to consider the allocation "Stack" to be 20x if all 20 were duplicates were required at the same time.

Obviously I've left out some of the implementation details of what the function is doing... but param changes what data the task (or duplicate tasks) are working on, with a variable _time_delay() in each task (determined by the data the task is working on).

If further clarification is needed to answer this question, let me know.

Jason

 

0 Kudos
Reply
1 Reply

1,485 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi @jbaker1 

 

From what I can see from the code, if you  use _task_create multiple times, then all the tasks have the same priority, and same stack size, same index, maybe those are not you want.

It is hard to debug since they have the same index.

So I would suggest you create multiple tasks with different index.

 

Regards

Daniel