Synchornization of Cores

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I'm working with one Aurix TC27x

In my little application two cores are working together (Core0 is a Producer, and Core1 is a Consumer). But I have some problems to share resources.

What is the typical mechanism to share a variable between them? How can synchronize the information? I have only used mutex and semaphores, but with only one core. So I do not know how to implement this other type of locking

Information about intercore comunications will be appreciated.

Thanks
Edgar Sevilla
0 Likes
2 Replies
Not applicable
Look at synchronization methods from ifx library:



typedef unsigned int IfxCpu_mutexLock;

boolean IfxCpu_acquireMutex (IfxCpu_mutexLock * lock)
{
boolean retVal;
volatile uint32 spinLockVal;

retVal = FALSE;

spinLockVal = 1UL;
spinLockVal = (uint32) __cmpAndSwap (((unsigned int *) lock), spinLockVal, 0);

/* Check if the SpinLock WAS set before the attempt to acquire spinlock */
if (spinLockVal == 0)
{
retVal = TRUE;
}

return retVal;
}


void IfxCpu_releaseMutex (IfxCpu_mutexLock * lock)
{
/*Reset the SpinLock */
*lock = 0;
}
0 Likes
Not applicable
Hi ,

Thank you for the detailed explanation. It helped a lot.

Best regards
Prakt
0 Likes