space_unused() does not seem to use adi_rtl_(un)lock_globals() to protect himself in a multi-threading environment.
Both space_unused() and heap_space_unused() are linked from the libc535mty.dlb library.
I'm building a C++ multi-threaded VDK application with VDSP++ 5.0 Update 10 for BF535.
During some parts of the program, new, new, delete and delete operators are used.
I use the space_unused() function in only one thread in my program and this is the thread which sometimes crashes without any obvious reason.
During a stability test today, using a Release build with the HPUSB-ICE emulator, my code crashed in with a misalignment exception in space_unused().
The thread containing space_unused() was interrupted by another one, presumably in the context of space_unused(). The interrupting thread has allocated for sure memory using new. When the interrupted thread has resumed the execution, a misalignment exception has occurred in the loop space_unused() implements to calculate the free memory.
I have "parsed" the heap memory "by hand", using the same algorithm space_unused() does and could not find that memory address which caused the misaligned access.