Date: Mon, 3 Oct 2011 07:19:12 -0700 From: mdf@FreeBSD.org To: lev@freebsd.org Cc: hackers@freebsd.org Subject: Re: Atomic increment and get? Message-ID: <CAMBSHm8dUvgBtzuekij2WJ5r3KGoEjDh5ENJoLXk%2B%2BXrYqUM5Q@mail.gmail.com> In-Reply-To: <558829232.20111003133754@serebryakov.spb.ru> References: <558829232.20111003133754@serebryakov.spb.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
2011/10/3 Lev Serebryakov <lev@freebsd.org>: > =A0Is here atomic increment and get (or add and get) operation in > =A0kernel? I cannot find one. Here is atomic_add_32(), but it doesn't > =A0return result. And here is no atomic_add_64() on 32 bit system :( See atomic_fetchadd_int. Not all hardware has 64-bit atomic instructions available in 32-bit mode so it's not machine-independent. Generally, for this case (and potentially for sub-32-bit atomic operations [1]) a lock is used. [1] with masking and shifting 32-bit atomics can be used to set data in an 8 or 16 bit variable; see a recent commit to sys/vm. Cheers, matthew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm8dUvgBtzuekij2WJ5r3KGoEjDh5ENJoLXk%2B%2BXrYqUM5Q>