Messages in this thread | | | Subject | RE: [Infiniband-general] Getting an Infiniband access layer in theLinux kernel | Date | Thu, 5 Feb 2004 20:07:56 -0800 | From | "Perez-Gonzalez, Inaky" <> |
| |
> From: Tillier, Fabian > ... > > Having atomic operations return a value allows one to do something like > test for zero when decrementing an atomic variable such as a reference > count, to determine whether final cleanup should proceed. This removes > the need for an actual spinlock protecting the reference count. As you > know, reading the value post-decrement does not guarantee that said > value reflects the result of only that decrement operation. It would be > catastrophic if two threads checked the value of a reference count > without proper synchronization - they could both end up running the > cleanup code with undesired (and perhaps catastrophic) results.
atomic_dec_and_test() does just that (asm/atomic.h).
Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |