__sync_fetch_and_add

Home » Asterisk Tips » __sync_fetch_and_add
Asterisk Tips 2 Comments

__sync_fetch_and_add is just a built in function (you don’t have to include anything to use them) for managing atomic variables when developing multithread applications in C++. There are several functions for working with atomic variables.

An atomic variable is that over which operations happens at once, that is, in the moment that some thread/process start reading/writing on it, nothing else interrupts that operation to and come in the middle.

An excellent article about Multithreaded simple data type access and atomic variables, by Alexander Sandler,  is available here.

2 thoughts on - __sync_fetch_and_add

  • Hey Kevin,
    nope, nothing…just doing the standard

    ./configure; make menuselect; make

    this is a Sun Sparc v240 machine running Debian 6.0 Squeeze sparc64-smp
    kernel

  • Ok, so this is solved! The culprit was the the line “mcpu=v8” in the
    Makefile. Comment that out, and it makes properly.