Many C runtimes will ship with an implementation of malloc, but the embedded, oriented versions won't necessarily be thread safe by default. Because each C runtime is different, the steps needed to make malloc thread safe will vary. The included STM toolchain used in this book includes newlib-nano as the C runtime library. The following are a few notes regarding newlib-nano:
- newlib-nano uses malloc and realloc for stdio.h functionality (that is, printf).
- realloc is not directly supported by FreeRTOS heap implementations.
- FreeRTOSConfig.h includes the configUSE_NEWLIB_REENTRANT setting to make newlib thread safe, but it needs to be used in conjunction with the appropriate implementations of all stubs. This will allow you to use newlib-based printf, strtok, and so on in a thread-safe manner. This option also makes general use case calls to malloc...