[Solved] Probably a basic C question

Hello,
Let s say I have two cores and they share a variable within the shared memory we all agree that if they both access it at the same time I will generate conflict and my board is very likely to crash. Now what if I define this structure :

struct shared_data
{
  uint8_t var1;
  uint8_t var2;
};
volatile struct shared_data * const buff = (struct shared_data *)SHARED_MEM_ADDRESS;

Will accessing buff->var1 on CORE1 and buff->var2 on CORE2 at the same time generate conflict? I mean the variable addresses are different but they are a part of the same structure.

not an expert here but using "volatile" as you have here is there to handle such possibilities and therefore eliminate/mitigate the risk of conflict.

hope that helps...

No...

volatile just instructs the compiler to not optimise read/write access to the variable and always fetch from/write to the original memory location for every access

so you still have a conflict if two cores can access (write) the same variable or if one can read whilst the other is modifying the bytes. You can use a mutex, semaphore etc for example to guard against simultaneous access.

accessing two different variables (think in terms of memory location) is not an issue

Look up "mutex" for this multi-core platform to see how that resource can be shared safely.

I already use Hardware Semaphore, from what I have read on mutex (and I read it quite fast so I might be wrong as hell) it does approximately the same thing by creating atomic locks and help avoid the issues linked to software semaphore (where a semaphore could be checked at the same time). Since I use HW semaphore I am not supposed to face this issue so I will keep my HW semaphore for now.
Thanks anyway for having me discover mutexes!