AnsweredAssumed Answered

Unexpected Behavior of Implementation of Priority Ceiling Protocol with INTC

Question asked by Peter Vranken on Mar 8, 2018
Latest reply on Mar 30, 2018 by Peter Vranken

I've experienced a unexpected behavior applying the Priority Ceiling Protocol with the INTC of an MPC5643L device. The code pattern proposed in the reference manual is:


    GetResource:
    wrteei 0 # disable external interrupts to the Processor
    raise PRI # Write to CPR, cache inhibit, guarded
    mbar # flush out writes from store buffer
    wrteei 1 # enable external interrupts to the Processor
    isync # re-fetch Processor pipeline


    ReleaseResource:
    mbar # flush out writes from store buffer
    wrteei 0 # disable external interrupts to the Processor
    lower PRI # Write to CPR, cache inhibit, guarded
    wrteei 1 # enable external interrupts to the Processor


The mentioned unexpected behavior are occasional preemptions of ISR A, which is executing pattern GetResource, by ISR B after A raising the current priority. B had a higher priority than A but still not higher than the priority written into CPR by A.


The intention of the code patterns, mutual exclusion of A and B, or shaping a critical code section between GetResource and ReleaseResource, is not harmed by this effect; the preemption of A only happened immediately after the "wrteei 1" in pattern GetResource; the very first instruction of A inside the critical code section was executed only after completion of and return from the preempting B. (This is currently my explanation why we need the isync in the GetResource pattern.)


It looks as if interrupts, which are asserted in the short period between the "wrteei 0" and the "raise PRI" are routed by the INTC to the CPU and that the CPU sees such an interrupt even after the update of CPR so that it handles the interrupt immediately after the "wrteei 1".


My questions:


Am I doing something wrong?

Am I misunderstanding something?

Is there anybody who can confirm my observations?

 

The observed behavior is critical for my use case of the PCP; therefore I would like to deeply understand it.

Outcomes