[Asterisk-Dev] Race issue in channel.c involving uniqueint on Asterisk 1.2.1

Kevin P. Fleming kpfleming at digium.com
Fri Jan 6 12:27:15 MST 2006


Luigi Rizzo wrote:
> in freebsd, and i believe other systems as well, there is a set of
> functions that do atomic manipulation of variables e.g.
> (from i386/include/atomic.h):

I have had this discussion with Mark previously... There were some 
issues the last time I looked (when I was working on using atomic ops 
for object reference counts in astobj2):

1) FreeBSD (at the time) did not have atomic_dec_and_test, which is 
vital for reference count implementation.

2) The Linux headers don't necessarily provide atomic behavior (as dwmw2 
has already posted); it depends on how they are configured. Forcibly 
defining CONFIG_SMP before including asm/atomic.h helps to work around 
that problem. There is also the issue of these files being GPL licensed 
and producing object code that ends up in non-GPL Asterisk binaries, but 
that's a bit of a gray area since the code also appears in other places 
(other projects) and code from header files is sometimes treated 
differently.

3) Using these operations will make an enormous performance difference 
between the platforms where they are easy to provide (Linux and FreeBSD) 
and other platforms. Granted this is not as large an issue, but it's 
still something to be aware of.



More information about the asterisk-dev mailing list