2024-10-22 09:48 AM - edited 2024-10-22 09:50 AM
Hi,
In the RFAL library I see that the global variable st25r3916interrupt.status is protected using platformProtectST25RIrqStatus() while writing to this global variable. While reading st25r3916interrupt.status I see that it is not protected using platformProtectST25RIrqStatus() and do you think this will be okay in a multithreaded environment ? Will not this result in reading half-updated value ? For example: See the below code:
/*******************************************************************************/
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo )
{
uint32_t tmrDelay;
uint32_t status;
tmrDelay = platformTimerCreate( tmo );
/* Run until specific interrupt has happen or the timer has expired */
do
{
status = (st25r3916interrupt.status & mask);
} while( ( (!platformTimerIsExpired( tmrDelay )) || (tmo == 0U)) && (status == 0U) );
platformTimerDestroy( tmrDelay );
status = st25r3916interrupt.status & mask;
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~status;
platformUnprotectST25RIrqStatus();
return status;
}
2024-10-23 12:02 AM
Hi Daan1,
reading is not harmful in this one producer - one consumer scheme. The consumer will only clear what it has consumed (transferred into its status variable).
BR, Ulysses