This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM263P4-Q1: Lock/Unlock Spinlock API

Part Number: AM263P4-Q1

Tool/software:

Hi Team,

I received question from customer regarding spinlock. 

Is it possible to lock/unlock by calling the SPINLOCK API during an interrupt?

https://software-dl.ti.com/mcu-plus-sdk/esd/AM263PX/09_02_00_56/exports/docs/api_guide_am263px/group__DRV__SPINLOCK__MODULE.html

Best regards,

Mari Tsunoda

  • Hey Mari,

    It is a plausible use-case to lock/unlock during an interrupt service routine. Just remember the 3 requirements for mutual exclusion for access to a shared data structure via the spinlock module.

    1. The time to hold the lock is predictable and small.
    2. The locking task cannot be preempted or suspended or interrupted while holding the lock. (This would make the hold time large and unpredictable.)
    3. The lock is lightly contended, that is the chance of any other process (or processor) trying to acquire the lock while it is held is small.

    #2 of the list above might be of concern depending on the expectations of the ISR.

    Best Regards,

    Zackary Fleenor