This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interruptibility of memset() on C64x

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():

  1. 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;
      }

  2. 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

  • I filed the entry SDSCM00044047 in the SDOWP system to request that memset be changed so it can be interrupted.  Feel free to track that request with the SDOWP link below in my signature.  I also added a short paragraph to this related wiki article.

    Thank and regards,

    -George

  • Looks like the complier team shot down the change request.  Can you list all the RTS functions that disable interrupts?  So far my bouncing around the Forum and Wiki articles I've found:  memset( )  and strcpy( ).  However I bet there are more.

    Thanks, Dean

  • In theory, any RTS function could, due to a long running loop, disable interrupts for any number of cycles.  In practice, you only need to worry about the ones that might operate upon a large amount of data.  Anything from <string.h>, bsearch, qsort, that sort of thing.  I'm not aware of any specific list of these functions.

    Thanks and regards,

    -George

  • How do you suggest we handle cases where a TASK or IDLE loop works on large amounts of data (memset with a large data buffer for example) AND we need to keep our real time requirements (audio samples to a codec for example)?

    It would be really helpful if TI could list the functions that disable interrupts.  Either directly by changing the GIE bit, or in-directly through a SLOOP optimization.

    - Dean

     

  • One method is suggested in the first post in this thread.  If that isn't good enough, you can build a custom RTS library that uses the option --interrupt_thread=cycle_count to insure interrupts are disabled no more than cycle_count CPU cycles.  Details on building the RTS are in this wiki article.

    Thanks and regards,

    -George