Is newlib-nano thread safe?

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

Is newlib-nano thread safe?

Jump to solution
725 Views
fernando_dabadia
Contributor I

Hi,

I did a search but couldn't find reliable information.
Could someone confirm for me if the newlib-nano delivered in the MCUXpresso package is thread safe?

Sincerely,

Fernando

Labels (1)
0 Kudos
Reply
1 Solution
683 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @fernando_dabadia ,

Newlib and newlib-nano are part of the GNU ARM Embedded Toolchain distribution maintained by ARM. The IDE includes the package in unmodified binary form. Newlib requires FreeRTOS platform support to provide thread-safety. But we haven't such example.

https://community.nxp.com/t5/LPC-Microcontrollers/Newlib-none-C-exceptions-and-thread-safety/td-p/11...

https://nadler.com/embedded/NXP_newlibAndFreeRTOS.html

https://github.com/DRNadler/FreeRTOS_helpers

 

Regards,

Jing

View solution in original post

0 Kudos
Reply
2 Replies
684 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @fernando_dabadia ,

Newlib and newlib-nano are part of the GNU ARM Embedded Toolchain distribution maintained by ARM. The IDE includes the package in unmodified binary form. Newlib requires FreeRTOS platform support to provide thread-safety. But we haven't such example.

https://community.nxp.com/t5/LPC-Microcontrollers/Newlib-none-C-exceptions-and-thread-safety/td-p/11...

https://nadler.com/embedded/NXP_newlibAndFreeRTOS.html

https://github.com/DRNadler/FreeRTOS_helpers

 

Regards,

Jing

0 Kudos
Reply
655 Views
fernando_dabadia
Contributor I

Hi @jing,

Thanks for the answer. I read the material recommended by you and several others that I found on the internet, in addition to performing some tests myself (which I had already done in the past). From what I could see, newlib-nano behaves the same way as newlib, when it comes to the thread-safe requirement. I had already implemented several hooks functions (even before this question) required by the newlib in addition to wrapping the malloc, malloc_r, free and free_r functions (I am using FreeRTOS and calling the pvPortMalloc and vPortFree functions in the wrap). From what I could see, the newlib's operations (printf, for example) are always using mutexes to protect events (using the hook functions I implemented).

However I still have some sporadics Hard Faults in my code, which is messing the process stack (where it points to). I'm still under investigation, in the past I had a similar problem when I was using the standard libraries without the necessary implementations for thread-safe (before I was using IAR and now GCC/MCUXpresso), that's why I posted this question, even having previously implemented what was demanded by newlib to make it thread-safe.

Thanks,

Fernando.

0 Kudos
Reply