Hello!
I am trying to port freertos smp and reference RP2040
I have confusion about acquiring lock:
if( uxAcquire )
{
if( __builtin_expect( !*pxSpinLock, 0 ) )
{
if( ucOwnedByCore[ulCoreNum] & ulLockBit )
{
configASSERT(ucRecursionCountByLock[ulLockNum] != 255u );
ucRecursionCountByLock[ulLockNum]++;
return;
}
while ( __builtin_expect( !*pxSpinLock, 0 ) );
}
__mem_fence_acquire();
configASSERT(ucRecursionCountByLock[ulLockNum] == 0 );
/* there needs a operation to mark the pxSpinLock? */
ucRecursionCountByLock[ulLockNum] = 1;
ucOwnedByCore[ulCoreNum] |= ulLockBit;
When a task acquires lock successfully,it should change ‘ pxSpinLock’ value to 0 to indicating the lock is acquired.
Besides, I do not think this spinlock implement is mutual exclusion.
Best regards