Linux的原子操作与同步机制

static inline int atomic_add_return(int i, atomic_t *v)

{

    unsigned long tmp;

    int result;

    __asm__ __volatile__("@ atomic_add_return\n"

      "1:    ldrex  %0, [%2]\n"

      "      add    %0, %0, %3\n"

      "      strex  %1, %0, [%2]\n"

      "      teq    %1, #0\n"

      "      bne    1b"

      : "=&r" (result), "=&r" (tmp)

      : "r" (&v->counter), "Ir" (i)

      : "cc");

    return result;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4b58d3e5cc1bdd73e99dc6be36328419.html