[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: atomic_ops vs mutex
On Sat, Nov 07, 2009 at 03:21:48AM +0000, raymond.meyer%rambler.ru@localhost
> I have two questions:
> 1. Are all atomic_ops functions, or some of them macros?
They are functions as documented in the manual page (at least as far
as I can tell).
> 2. In what cases would it be better to use atomic_ops, instead of
> locking and unlocking mutex?
It depends what your application is doing. Locking and unlocking a
mutex requires (at least) two atomic operations. If you e.g. want
to update a single number an atomic operation will be cheaper.
If you want to update at least three a mutex will cause less
overhead. If you need to keep multiple variables consistent (e.g.
the head and tail pointer of a list) you will need a mutex.
Matthias Scheler http://zhadum.org.uk/
Main Index |
Thread Index |