AnsweredAssumed Answered

atomic instructions functions in VDK

Question asked by tcmichals on Mar 3, 2010
Latest reply on Mar 3, 2010 by vapier

I'm porting some x86 code and use functions like atomic_exchange_and_add, atomic_increment etc...

Is there a blackfin instruction to allow this type of operation?  Or just disable interrupts?

 

inline void atomic_decrement( volatile int * pw, int incr = 1 )
{
    //atomic_exchange_and_add( pw, 1 );
    __asm
    {
        mov eax, incr
        mov esi, [pw]
        lock sub dword ptr [esi], eax
    }
}

 

inline int atomic_compare_and_exchange( int * pw, int equals, int setto )
{
    //atomic_exchange_and_add( pw, 1 );
    //if equals == *pw
    //    *pw = setto
    //    return equals
    //else
    //    return *pw
    __asm
    {
        mov eax, equals
        mov edi, setto
        mov esi, [pw]
        lock cmpxchg dword ptr [esi], edi
    }
}

 

Or does this just have to lock out interrupts to insure this?

Outcomes