This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Instruction cpsie i and bx LR is not atomic.

Hi All,

        I have a proprietary OS Implemented in our Project and its running on ARM Cortex M7.  To exit ISR handler we use these 2 instructions. 

cpsie i
bx LR

The sequence of the flow is as follows

1. Low Priority Task is running. (LowPriority_TASK)

2. Low priority interrupt occurred (LowPriority_ISR). PC jumps to this LowPriority_ISR handler and starts execution.

3. Before exiting this ISR Handler we restore the context of the  pre-empted task i.e. LowPriority_TASK. During this Context restoring a new high priority ISR is Triggered. (HighPriority_ISR).

5. Thus immediately after cpsie i, the PC jumps to HighPriority_ISR handler. In this HighPriority_ISR handler we have set few Events which makes a Higher priority Task (HighPriority_TASK) in ready state. 

6. HighPriority_ISR  is finished and the PC returns to LowPriority_ISR. Here there only one instruction bx LR pending to be executed. PC executes this instruction and the control is passed to LowPriority_TASK. Even though the HighPriority_ISR  is in ready state the scheduler cannot load it till next task or ISR is triggered.

Although this problem will not occur if there is single atomix instruction available which will load the context and enable interrupts e.g rfe sp! or ret which is not available in Cortex M7

DO any body have faced this type of issue. if yes is there any solution for this.

Regards.