gwonos wrote on Thursday, August 09, 2018:
I want to know if FreeRTOS can use the standard library.
I would like to use functions like printf, scanf, malloc and so on. Is it true that I can not use the standard library as I found it?
I want to know if I can use the standard library even now.
What should I do if I want to use the standard library functions?
Is newlib available to me?
I am currently using FreeRTOS to port mips.
I confirmed the task scheduling behavior by replacing only the memory address and interrupt in the mips32 GCC project created by imagination, not the officially supported core.
compile was done using the codescape toolchain in the linux environment.
I want to know what I need to do to use standard libray or newlib.
rtel wrote on Friday, August 10, 2018:
The answer is … “it depends”.
There are many different standard libraries, not just one. Some are written specifically for small embedded systems and are careful to use little stack, no malloc calls, etc. - while others just aren’t. In all cases you have to check to see if the functions you use are thread safe.
As you ask specifically about newelib in particular, then as a general rule newlib is not a good implementation for small embedded systems as it assumes Linux like resources. In particular, it can unexpectely call malloc() in printf() - which is not good if you are using pvPortMalloc() in place of malloc(). Likewise some, although just a few functions, are not inherently thread safe.
If you want some kind of thread safety then you may have to implement malloc() locks unless you stick to FreeRTOS’s memory allocators, and you may have to define configUSE_NEWLIB_REENTRANT.