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.

"volatile" and "interrupt_threshold"

Hello,

 

spru187.pdf denotes in chapter 6.5.6 "The volatile keyword" that "--interrupt_threshold" should be set to 1, if you use the volatile keyword. But this setting would degrade the performance (we're targetting the C6748, not sure about the impact of the SPLOOP instruction there). Is it possible to set "--interrupt_threshold" to 300 when using "volatile"? What would be the consequences?

  • Feel free to experiment (and only experiment) with --interrupt_threshold=300.  In the meantime, I'll check on why the book says that.

    Thanks and regards,

    -George

  • Using --interrupt_threshold=300 is fine.  The compiler book is a bit paranoid on this.  It is correct to say that not specifying --interrupt_threshold at all will create problems.  By default, compiler generated code can disable interrupts for an unlimited number of cycles.  In a case such as this ...

    volatile int gate;
    ...
        while (!gate) /* wait here */ ;

    That spin loop could generate code that never allows interrupts.  With interrupts disabled, the value of gate can never be changed.  Thus, this becomes an endless loop.  Not good.

    While using --interrupt_threshold=1 fixes this problem, it is overkill.  Using --interrupt_threshold=300 will fix it as well.

    For more background on how and when the compiler may disable interrupts, please see this wiki article.

    Thanks and regards,

    -George