[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141219000416.689f3ab7@mdontu-l.dsd.ro>
Date: Fri, 19 Dec 2014 00:04:16 +0200
From: Mihai Donțu <mihai.dontu@...il.com>
To: "Rogelio M. Serrano Jr." <rogelios664@...il.com>
Cc: linux-kernel@...r.kernel.org, pageexec@...email.hu
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists