A couple garbage collector questions
Andrew Kuchling
akuchlin at mems-exchange.org
Wed Apr 4 14:56:45 EDT 2001
Douglas Alan <nessus at mit.edu> writes:
> Why do you need to lock on increment/decrement? Isn't incrementing or
> decrementing an integer an atomic operation on most CPU's?
Yes, but you don't know if your C compiler is smart enough to generate
such code for obj->refcnt++, so usually bits of assembler are used.
For example, on Linux there are atomic_inc() and atomic_dec() macros
in asm/atomic.h. I doubt there's a way of doing this portably.
--amk
More information about the Python-list
mailing list