UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor @bucky
Visitor
150 Views
Registered: ‎11-22-2018

Shared Variable on IRQ & Out-of-Order execution

Jump to solution

Hi guys,

I have got a doubt about out-of-order execution and interrupts.
As far as I've understood the CPU is allowed to re-order instruction execution at runtime as long as the original program flow is met.

I'm not sure if the latter info is true also in case of interruption.

I've an IRQ that shares with main program loop a flag accessed in atomic way.
I'm not sure that the flag is actually written when I intend to - does the CPU completes the memory accesses before servicing any interrupt?

 

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Voyager
Voyager
122 Views
Registered: ‎04-13-2015

Re: Shared Variable on IRQ & Out-of-Order execution

Jump to solution

@bucky

Your worry is justified but at the end the CPU going into interrupt code is barely different from it performing a branch.  When the CPU does a write, the data can land in memory quite late after the instruction, even in non-interrupted code.  If you want the flag you set to be memorized when that instruction executes and not after, you have to insert a "DMB" instruction after the write instruction (I assume you are on the A9 as it's a different instruction on the A53).

 

0 Kudos
1 Reply
Voyager
Voyager
123 Views
Registered: ‎04-13-2015

Re: Shared Variable on IRQ & Out-of-Order execution

Jump to solution

@bucky

Your worry is justified but at the end the CPU going into interrupt code is barely different from it performing a branch.  When the CPU does a write, the data can land in memory quite late after the instruction, even in non-interrupted code.  If you want the flag you set to be memorized when that instruction executes and not after, you have to insert a "DMB" instruction after the write instruction (I assume you are on the A9 as it's a different instruction on the A53).

 

0 Kudos