Skip to main content
Explorer
October 22, 2024
Solved

RFAL st25r3916interrupt.status protection

  • October 22, 2024
  • 1 reply
  • 688 views

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

 

    This topic has been closed for replies.
    Best answer by Ulysses HERNIOSUS

    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

    1 reply

    Technical Moderator
    October 23, 2024

    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