how to set the task priorities in MQX OS ?

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

how to set the task priorities in MQX OS ?

2,059 Views
sivakumarananth
Contributor I

Hi all,

1.       Working with MQX RTOS , Need to know how to set the task priorities for the task ?

2.       How to view and set  the Memory addresses in the Software ?

3.       Is the Priorities are automatically set or need to set it manually ?

Thanks

Siva Kumar A

0 Kudos
6 Replies

1,042 Views
RadekS
NXP Employee
NXP Employee

1)

Look at MQX_template_list[]:

const TASK_TEMPLATE_STRUCT MQX_template_list[] =

{

/* Task Index,  Function, Stack,  Priority, Name,    Attributes,          Param, Time Slice */

{ HELLO_TASK,  hello_task, 1500,  8, "hello", MQX_AUTO_START_TASK, 0,    0 },

{ 0 }

};

Here you see task priority 8. Lower priorities (0..7) are used for interrupts. Please do not use lower priorities for tasks.

In fact, you can create and destroy tasks dynamically, however do not forget that you can create only task with priority which is the same or lower than maximum priority used in MQX_template_list[].

2)

For now I suppose that you use CodeWarrior. Here is answer:

https://community.freescale.com/message/382132#382132

3)

Manually.


Have a great day,
Radek

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

0 Kudos

1,042 Views
razed11
Contributor V

Hi Radek,

I've used many RTOSes but I'm new to MQX. I don't understand your comment about priorities 0-7 being reserved for interrupts. Why would interrupt priorities and task priorities have anything to do with one another? Are software interrupts being used somehow?

Thanks,


K

0 Kudos

1,042 Views
RadekS
NXP Employee
NXP Employee

It is simply. In MQX TASK_PRIORITY - the lower number = the higher priority. Task with priority 0 disables all the interrupts. Priorities 0 to 8 are used by the OS Kernel and interrupts.

So, if you create task with priority for example 5, you will effectively block all interrupts and MQX kernel tasks with priority 6 and 7 (plus other tasks with higher priority numbers). In that case, there is big chance that part of operating system will not work.

About interrupts)

MQX_User_Guide: Kinetis K MCUs support 16 hardware interrupt priority levels. Internally MQX RTOS maps even levels (0, 2, 4, .., 14) for MQX applications while odd levels (1, 3, .., 15) are used internally. MQX application interrupt levels are 0 to 7, the mapping from MQX application levels 0 to 7 to hardware priority levels (0, 2 to 14) is implemented in the _bsp_int_init() function.

Note: If you want create some highest priority interrupt out of MQX (for example for periodical PWM update), please don’t use odd hardware interrupt priority levels (1, 3, .., 15). Additionally you cannot use any API functions from MQX.


Have a great day,
RadekS

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

0 Kudos

1,042 Views
razed11
Contributor V

That still makes little or no sense to me. That last paragraph in particular. An interrupt priority has nothing to do with whether or not an MQX API call can be made. This is true if you install your own ISR handler and it is a so-called zero latency interrupt because it is not wrapped by the MQX framework handler.

Since I posted my question I learned that task priorities 0-7 install different BASEPRI and *this* is the connection between task and interrupt priorities. I consider task priorities 0-8 to be reserved and 9 through whatever number I want is limited only by memory. The lowest priority (highest number) possible is defined by the static task template which is important if tasks are dynamically created as is this case in my application. For these nonreserved tasks the BASEPRI is zero which means all interrupts are free to execute.

What fundamentally doesn't make sense is this business of odd and even ISR priorities. If I install my own PWM update ISR and do not call any MQX services I don't see how it can matter whether my priority is even or odd. It only matters what that value is relative to other interrupts. Furthermore without knowing how those priorities are used by the framework I don't know how I can choose a priority intelligently--odd or even tells me nothing.

I'm sure you understand what you are talking about it's just that language that you and the user guide have chosen to describe things is not clear to me.

0 Kudos

1,042 Views
sivakumarananth
Contributor I

Hi Radek,

    Thank You Very Much. In MQX when the tasks are assigned in the task template list, the stack size, priority and attributes are followed by a L character, For example 1000L in stack size and in priority 10L, 24L. What does this mean ?

Thanks in Advance ,

Siva Kumar A 

0 Kudos

1,042 Views
RadekS
NXP Employee
NXP Employee

Letter at end of number is suffix.

Without a suffix, the compiler chooses int, uint, long, ulong according to the size of number. You can also use the suffix letters U,u, l or L. U and u means unsigned, L or l means long. Any 2 letter combination of these letters UL, ul, UL,Ul is ok.

So, suffix is way how to force compiler to use correct number type. For most things, it's unnecessary, as the compiler will automatically form whatever type that it thinks is right for the number given, but for example small numeric constants may not be promoted to long when combined with other "small" numbers.

We can say that is good habit in use of suffixes, because we ca use several different compilers for MQX code and we wants the same behaviour in all cases....

0 Kudos