Boost logo

Boost :

Subject: Re: [boost] [lockfree] Review
From: Grund, Holger (Holger.Grund_at_[hidden])
Date: 2011-08-05 14:54:50


Hi Helge,

>
> keep an "even" and an "odd" copy of your data structure, keep an
> atomically
> readable "generation counter" -- on access, read the generation
> counter, read
> the data (depending on parity of generation counter), read the
> generation
> counter again
>
> if it changed, start over. if it didn't change, you have your data; on
> modification, update generation counter as appropriate (if you are
> paranoid
> about counter overflows, you can repeat a similar trick with the
> counter
> itself)
>
> no need for anything larger than word-sized atomics here, size of
> shared
> read-only data structure does not matter
>
Agreed, this is not impossible, but I still tend to think we should strive for a more efficient implementation if at all possible.

> > I don't think you want misaligned data with atomics -- ever. How
> would you
> > ensure not to cross a cacheline or even a page?
>
> you don't -- if an x86 processor detects the access to be misaligned,
> it will
> issue a bus lock instead of doing RMW in cache

Oh I see, what you mean now. As you said, that's not a terribly efficient thing to do these days, though.

Anyway, this diverging quite a bit from Lockfree. I would certainly love to see a useful implementation of <atomic>. We care mostly about Linux here, but Windows would be quite nice, too. If there's anything I can do to get this moving let me know.

Thanks!
-hg

--------------------------------------------------------------------------
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk