Messages in this thread | | | Date | Fri, 19 Dec 2014 00:04:16 +0200 | From | Mihai Donțu <> | Subject | Re: atomic_inc and spin_lock_irq |
| |
On Thu, 18 Dec 2014 21:07:46 +0000 Rogelio M. Serrano Jr. wrote: > whats the difference between: > > atomic_inc(&port->count);
It is intended to atomically increment a variable of a standard size (int/long). See [1] for more information.
> and > > spin_lock_irq(&port->lock); > ++port->count; > spin_unlock_irq(&port->lock);
These are intended to be used when larger changes are to be made in an atomic fashion (not just increments). See [2] for details and [3] for an example.
[1] https://en.wikipedia.org/wiki/Fetch-and-add [2] http://lxr.free-electrons.com/source/include/linux/spinlock_api_smp.h#L104 [3] http://lxr.free-electrons.com/source/arch/x86/mm/mmio-mod.c#L265
-- Mihai Donțu
| |