Hello,
I just want to share my experience with the memset() function which is provided in the RTS library. It caused some trouble with real-time bahaviour of our applications. memset() is often used to initialize image buffers for example, which can be very big. The problem is that the loop in this function is not interruptible for the C64x core because it is always executing in a delay slot of a branch.
To solve this problem, we made two changes to memset():
- Use of #pragma UNROLL(8) to make the core loop larger than 5 cycles
if (len > 15)
#ifndef _TMS320C6400_PLUS
#pragma UNROLL(8);
#endif
for (i = 0; i < len >> 4; i++)
{
_amemd8(dst1) = dfill1; dst1 += 16;
_amemd8(dst2) = dfill2; dst2 += 16;
post_bytes -= 16;
} - Use of #pragma FUNC_INTERRUPT_THRESHOLD(memset , 8) to make sure the generated loop will be interruptible
#ifndef _TMS320C6400_PLUS
#pragma FUNC_INTERRUPT_THRESHOLD(VIB_Memset , 8);
#endif
void *memset(void *dst, int fill, size_t len)
I think it would be a good idea to include these changes in the RTS library. The additional overhead for the unrolled version of the loop isn't very big in my opinion.
Regards,
Ralf