Boost logo

Boost Users :

Subject: Re: [Boost-users] [interprocess] named_upgradable_mutex
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-07-02 05:39:21


Moritz escribió:
> The reason why I asked if this is correct proceeding, is that I can
> observe the described behavior on my machine. Actually the writer is a
> write-only process whose writing frequency is not predictable.
>
> So I tested this:
>
> reader1->u_mtx.lock_sharable(); // does not block
> reader2->u_mtx.lock_sharable(); // does not block
> writer->u_mtx.lock(); // does block
> reader3->u_mtx.lock_sharable(); // does block (until the writer has
> finished its operation)
>
> This is reproducible on my machine so I asked myself if this is the
> intended behavior. It would be exactly what I am looking for.

If the writer succeeds acquiring the exclusive lock (and to get this, it
will need to wait until all readers finish their job), then every other
attempt will block until the writer finishes. That's guaranteed.

Regards,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net