Re: C++, mutable member cache synchronization via double-checked-guard - is my idea correct?



"Mirek Fidler" <cxl@xxxxxxxxxx> wrote in message news:4bd1a0e5-2a9f-4996-b4ab-597e51c490bc@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 28, 1:51 am, "Chris Thomasson" <cris...@xxxxxxxxxxx> wrote:
> "Mirek Fidler" <c...@xxxxxxxxxx> wrote in message
>
> news:d62857bf-8475-4882-bd1c-f3aaa063f004@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> On Apr 27, 4:27 pm, "Dmitriy V'jukov" <dvyu...@xxxxxxxxx> wrote:
>
> > > On 27 ÁÐÒ, 17:14, Mirek Fidler <c...@xxxxxxxxxx> wrote:
>
> > > > > I see little problem here. You are loading double value which > > > > > can be
> > > > > concurrently modified. Store and load of 'sinx' must be atomic.
>
> > > > Pardon my ingorance, but is not it guaranteed by mutex?
>
> > > Modification always guarded, but load of value in Get() usually not
> > > guarded. So you can load value in middle of modification.
> > Ah, I see. You suppose that the problem is concurrent Set with Get?
> > But that cannot happen by interface defintion - client code would have
> > to protect against this e.g. using some for of rwlock (as correctly
> > demonstrated by Peter Dimov's post).
>
> Well, why not use an opportunistic upgradeable rwlock? If client code > needs
> to synchronize access anyway, I don't see why this something like this > could

Ehm, ops.

I guess we are just having terminology mismatch. In fact, what you
propose is exactly what I have wanted since the very beginning. (Just
reread the first post :)

I guess the only difference is that you are using a sort of spinlock
to implement DCL (or DCL-like algorithm) instead of Mutex, right?

It's not really a spinlock, well, its like a adaptive mutex with a bounded spin-count of 1. The reader tries to upgrade it self to a writer. If that fails, it releases read-access and acquires write, re-evaluates the dirty flags and acts accordingly. This would need to be documented. Since reader access was acquired externally, well, when it fails to upgrade and does the rdunlock-wrlock it invalidates the previously acquired read-access.




And also, my DCL implementation was a little bit less effective
because those memory barriers are not really necessarry, as they are
performed by rwlock synchronization primitives in the client code
anyway.

Your going to need at least release barrier before you set the flag to false.

.



Relevant Pages

  • Re: Bad sectors... how bad?
    ... > SP2's release, and then the remaining post SP2 updates after that. ... Someone said that I don't have to load the previous versions, ... All the others are upgrade disks, ... You pay $100 for an upgrade, and then you have to go out get the patches ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Bad sectors... how bad?
    ... Just load SP2, which includes all updates prior to ... All the others are upgrade disks, ... > defective so you have to download patches the day you load it. ... > with a vulnerable OS waiting for all the patches to download and install ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Reloading full Windows XP on a previously 98ME upgraded to XP
    ... still think you will run into problems because you have used your laptop CD. ... 98ME first and then use the upgrade disk. ... me load XP directly. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Is Trend Micro CSM 3.0 Good to go with SBS 2003 SP1?
    ... troubleshooting this but after initial load it is a lot quicker. ... especially regarding the 2.0 to 3.0 upgrade. ... will give this a try on my test server and see how it goes. ... Notify_Subject=Security Server Report ...
    (microsoft.public.windows.server.sbs)
  • Re: C++, mutable member cache synchronization via double-checked-guard - is my idea corr
    ... So you can load value in middle of modification. ... But that cannot happen by interface defintion - client code would have ... why not use an opportunistic upgradeable rwlock? ... my DCL implementation was a little bit less effective ...
    (comp.programming.threads)