AnsweredAssumed Answered

STREX/LDREX question

Question asked by Legrand.Thomas.001 on Dec 4, 2013
Latest reply on Dec 4, 2013 by Legrand.Thomas.001

I'd like to implement synchonization with LDREX / STREX.

What I don't understand is when I have multiple values to access with synchronization ...

void task1(void)
    ldrex var1;
void task1(void)
    ldrex var2;

(syntax is wrong but you get it).

Now what happens if task1 executes its ldrex, is preempted, context switch to task2, then task2 executes ldrex, then strex (what would be the result there ?), then context switch to task1 and task1 executes its ldrex ?

If it is unpredictable, then it means application should always use the same location for ldrex/strex, or did I miss something?