Are there any risks to using stdlib qsort() on an MQX 4.2 Kinetis K60 system?

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

Are there any risks to using stdlib qsort() on an MQX 4.2 Kinetis K60 system?

Jump to solution
628 Views
dmitriyc
Contributor III

Hello,

I would like to sort an array of structs and the qsort() in stdlib.h looks like a good solution as opposed to rolling my own sort function. I don't need that much speed, so the generic standard function should be fine for this. Are there any dangers in doing this? For example, is the qsort() implemented as a recursive function, creating the need to be very careful with the task's stack size?

Has anyone else had experience using qsort in an MQX system?

Tags (2)
0 Kudos
1 Solution
409 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi dmitriyc,

As you say... You must be very careful with the task stack. I have not tried qsort() or other recursive functions. But in my experience I saw that printf() using floats will overflow a task's stack very fast.


Best regards,
Carlos

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

View solution in original post

0 Kudos
1 Reply
410 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi dmitriyc,

As you say... You must be very careful with the task stack. I have not tried qsort() or other recursive functions. But in my experience I saw that printf() using floats will overflow a task's stack very fast.


Best regards,
Carlos

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

0 Kudos