MQX Lite - making a task ready

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

MQX Lite - making a task ready

Jump to solution
1,861 Views
dsherman
Contributor III

Bear with me, this seems like it should be something simple, but the MQX Lite documentation isn't helping much with this.  I have made two tasks in PE.  Under the task settings, you can enable or disable the auto start.  So let's say I want one task to run to initialize something, then let task 2 run.  If I've made task 1 auto start and task 2 isn't, how do I start task 2?  What is the difference between a task descriptor and task ID?  All the examples I see use _create_task_at() to return the task ID.  I can't even find the word "descriptor" in the MQX Lite user's guide.  I think I want to use _task_ready() to start it, but it seems like there's no direct way of getting the descriptor for it.

1 Solution
398 Views
soledad
NXP Employee
NXP Employee

Hi David,

We have an example for this in:

c:\Freescale\CW MCU v10.x\MCU\CodeWarrior_Examples\Processor_Expert\MQXLite\Kinetis\FRDM_KL25Z\LED_KL25Z\

Task1_task is an autostart task, and the Task2_task is created by _task_create_at().

Please refer to that example in the CodeWarrior 10.x installation folder.

Please check the below text from the MQX user guide, this may clarifies your doubt.

3.3.1 Creating Tasks

Any task (creator) can create another task (child) by calling _task_create(), _task_create_at()or _task_create_blocked(), and passing the processor number, a task template index, and a task-creation parameter. The application defines one creation parameter, which is normally used to provide initialization information to the child. A task can also create a task that is not defined in the task template list, by specifying a template index of zero. In this case, MQX interprets the task-creation parameter as a pointer to a task template.

The functions initialize the child's stack. The function _task_create() puts the child in the ready queue for the task's priority. If the child is of higher priority than the creator, the child becomes the active task, because it is the highest-priority ready task. If the creator is of higher or equal priority, it remains the active task.

The function _task_create_blocked() creates a task that is blocked. The task is not ready to run, until another task calls _task_ready().

The function _task_create_at() creates a task with the stack location specified, i.e. task stack is not dynamically allocated but has to be allocated before the

_task_create_at()function is issued.

3.3.2 Getting Task IDs

A task can directly get its task ID with _task_get_id(). If a function takes a task ID as a parameter, you can specify MQX_NULL_TASK_ID to refer to the task ID of the active task.

A task can directly get the task ID of its creator with _task_get_creator(). The function _task_create() returns the child's task ID to the creator.

A task ID can also be determined from the task name in the task template, from which the task was created. This is done with _task_get_id_from_name(), which returns the task ID of the first task that matches the name in the task template list.


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
399 Views
soledad
NXP Employee
NXP Employee

Hi David,

We have an example for this in:

c:\Freescale\CW MCU v10.x\MCU\CodeWarrior_Examples\Processor_Expert\MQXLite\Kinetis\FRDM_KL25Z\LED_KL25Z\

Task1_task is an autostart task, and the Task2_task is created by _task_create_at().

Please refer to that example in the CodeWarrior 10.x installation folder.

Please check the below text from the MQX user guide, this may clarifies your doubt.

3.3.1 Creating Tasks

Any task (creator) can create another task (child) by calling _task_create(), _task_create_at()or _task_create_blocked(), and passing the processor number, a task template index, and a task-creation parameter. The application defines one creation parameter, which is normally used to provide initialization information to the child. A task can also create a task that is not defined in the task template list, by specifying a template index of zero. In this case, MQX interprets the task-creation parameter as a pointer to a task template.

The functions initialize the child's stack. The function _task_create() puts the child in the ready queue for the task's priority. If the child is of higher priority than the creator, the child becomes the active task, because it is the highest-priority ready task. If the creator is of higher or equal priority, it remains the active task.

The function _task_create_blocked() creates a task that is blocked. The task is not ready to run, until another task calls _task_ready().

The function _task_create_at() creates a task with the stack location specified, i.e. task stack is not dynamically allocated but has to be allocated before the

_task_create_at()function is issued.

3.3.2 Getting Task IDs

A task can directly get its task ID with _task_get_id(). If a function takes a task ID as a parameter, you can specify MQX_NULL_TASK_ID to refer to the task ID of the active task.

A task can directly get the task ID of its creator with _task_get_creator(). The function _task_create() returns the child's task ID to the creator.

A task ID can also be determined from the task name in the task template, from which the task was created. This is done with _task_get_id_from_name(), which returns the task ID of the first task that matches the name in the task template list.


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
398 Views
dsherman
Contributor III


Thank you, Soledad.  I was looking at the MQX-Lite documentation, I didn't know the MQX documentation was still applicable.  I have my tasks running the way I'd like them to now.

0 Kudos