Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2001 19:02:20 -0500
From:      "Matthew Emmerton" <matt@gsicomp.on.ca>
To:        "John Baldwin" <jhb@FreeBSD.org>
Cc:        <freebsd-hackers@FreeBSD.org>
Subject:   Re: Atomic bit operations
Message-ID:  <00df01c08be2$3ff1e0e0$1200a8c0@gsicomp.on.ca>
References:  <XFMail.010131151628.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> On 31-Jan-01 Matthew Emmerton wrote:
> > Hi all,
> >
> > I've taken a look around for an implementation of atomic bit operations
in
> > FreeBSD (similar to Linux' asm/bitopt.h, which include clear_bit() and
> > test_and_set_bit()) but haven't found any.  The only thing I've found
are
> > the atomic clear/set/add/sub routines in machine/atomic.h.
> >
> > Do we have an implementation of atomic bit operations, and if we don't,
> > would we like some?
>
> Erm, atomic_set() sets's bits, and atomic_clear() clear's bits.  Anything
else
> you might need can be done with atomic_cmpset() anyways.

Where are these functions implemented?  /usr/include/machine/atomic.h just
has atomic_set_XXX and clear_XXX primitives, which work on char/short/longs,
but not individual bits.

I presume that I could wrap the char operations with something that takes
0x01 and bit-shifts it appropriately so that atomic_set/clear could be used.

However, certain other primitives are missing, such as an atomic
test-and-set operation.  Under the current scheme this would have to be done
by two independent operations, which is not useful when atomicitiy is
required.

--
Matt Emmerton



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00df01c08be2$3ff1e0e0$1200a8c0>