I user S32R274, it's a muti core MCUs and has hardware lock between cpus.
but , i think a mechanism like spin_lock/spin_lock_irqsave and atomic is needed in
muti-core MCU.
so I test like
static __inline__ int atomic_add_return(int a, atomic_t *v)
{
int t;
__asm__ __volatile__(
"1: lwarx %0,0,%2 # atomic_add_return\n\
add %0,%1,%0\n"
" stwcx. %0,0,%2 \n\
se_bne 1b"
SMP_ISYNC
: "=&r" (t)
: "r" (a), "r" (&v->counter)
: "cc", "memory");
return t;
}
but it seems not a atomic operation in a concurrent scenario。
So,do anyone know how to do it and pls tell me .
thanks a lot
Hi,
notice that reservation logic is not implemented between the cores. It can be used only on single core for multitasking.
Between the cores, it's necessary to use semaphores:
https://www.nxp.com/docs/en/application-note/AN4805.pdf
Regards,
Lukas