---------------------------------------- > Subject: RE: atomicity of x86 bt/bts/btr/btc? > From: foxmuldrster > To: jay > CC: gcc > Date: Tue, 19 Oct 2010 03:05:26 -0500 > > > > They do not automatically lock the bus. They will lock the bus with the > > > explicit LOCK prefix, and BTS is typically used for an atomic read/write > > > operation. > > > Thanks Rick. > > I'll go back to using them. > > I'm optimizing mainly for size. > > The comment should perhaps be amended. > > The "since they enforce atomic operation" part seems wrong. > > Np. For citation, see here (page 166). > > http://www.intel.com/Assets/PDF/manual/253666.pdf > > - Rick
Yep that was one of my references. It might be nice if optimizing for size would use them with code like e.g.: void set_bit(size_t* a, size_t b) { const unsigned c = sizeof(size_t) * CHAR_BIT; a[b / c] |= (((size_t)1) << (b % c)); } void clear_bit(size_t* a, size_t b) { const unsigned c = sizeof(size_t) * CHAR_BIT; a[b / c] &= ~(((size_t)1) << (b % c)); } int get_bit(size_t* a, size_t b) { const unsigned c = sizeof(size_t) * CHAR_BIT; return !!(a[b / c] & (((size_t)1) << (b % c))); } - Jay