Task priorities

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

Task priorities

Jump to solution
1,694 Views
matthewkendall
Contributor V

AN3905 ("Writing Your First MQX Application") has this advice on choosing priorities for user tasks:

"Do not assign higher priorities (0 - 8) to user tasks. Those are assigned to kernel and other important tasks."

I cannot find this limit anywhere else in the official MQX documentation. Neither the MQX Getting Started guide, nor the MQX User's Guide, nor the MQX Reference Manual have any mention of priorities reserved for the system, that I can find.

Is AN3905 correct; are some priorities reserved for system tasks, and if so is there a definitive list of these tasks and their priorities? Or is this advice incorrect or outdated in some way?


0 Kudos
Reply
1 Solution
722 Views
Martin_
NXP Employee
NXP Employee

Hello,

There are some components in MQX that execute in a task, examples (not a definitive list - sorry):

  Timer Task (default priority 1) - this is MQX timer component

  RTCS (TCP/IP) task (default priority 6)

  USB KHCI task (default priority 8)

  HTTPSRV server and session tasks (default priority 8)

  FTPSRV seerver and session tasks (default priotiy 8)

Especially RTCS server applications can create many tasks internally to handle connected clients in separate session tasks. If you look into Task Summary in TAD while your application executes, you will see all the tasks, including the ones created by system.

There is not such a restriction that user task shall not execute at task priority 0-8. But it shall be used only by users, who are aware of its interrupt mask feature and scheduling between "system tasks" and user tasks. 

View solution in original post

0 Kudos
Reply
3 Replies
723 Views
Martin_
NXP Employee
NXP Employee

Hello,

There are some components in MQX that execute in a task, examples (not a definitive list - sorry):

  Timer Task (default priority 1) - this is MQX timer component

  RTCS (TCP/IP) task (default priority 6)

  USB KHCI task (default priority 8)

  HTTPSRV server and session tasks (default priority 8)

  FTPSRV seerver and session tasks (default priotiy 8)

Especially RTCS server applications can create many tasks internally to handle connected clients in separate session tasks. If you look into Task Summary in TAD while your application executes, you will see all the tasks, including the ones created by system.

There is not such a restriction that user task shall not execute at task priority 0-8. But it shall be used only by users, who are aware of its interrupt mask feature and scheduling between "system tasks" and user tasks. 

0 Kudos
Reply
722 Views
matthewkendall
Contributor V

Thanks for the answer. I have an application that has been under development for some time, and I was looking at adjusting some task priorities, and I thought I remembered reading something about priorities being reserved for the system, and it took me a long time to find that it was in AN3905, and I was surprised to find that it was not mentioned elsewhere.

In my current system the only task I see running at a priority less than 8 is RTCS at 6 (the system is not currently using the MQX timer task, nor HTTP or FTP).

I assume there is no particular performance penalty to having several levels (0 to 5, 7 and 8) unused?

0 Kudos
Reply
722 Views
Martin_
NXP Employee
NXP Employee

No performance penalty.

However, memory consumption penalty exists for unused priorities between highest and lowest priority, as MQX allocates memory for ready queue for each task priority, up to the lowest priority listed in task template list:

When you assign task priorities in the task template list, note that:

• MQX creates one ready queue for each priority up to the lowest priority (highest number).

• While an application is running, it cannot create a task that has a lower priority (a higher number) than the lowest-priority task in the task template list.

The ready queue structure is not that large, but it makes no sense to give prio 8 along with prio 255 to the task template list, as there would be also ready queue for unused levels 6-254 in this scenario.

0 Kudos
Reply