cancel
Showing results for 
Search instead for 
Did you mean: 

RFAL st25r3916interrupt.status protection

Daan1
Associate II

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;
}

 

1 REPLY 1
Ulysses HERNIOSUS
ST Employee

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