Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] why isn't it possible to acquire 2 different upgrade_lock from 2 different threads?
From: Brian Budge (brian.budge_at_[hidden])
Date: 2014-03-27 13:00:36


On Thu, Mar 27, 2014 at 9:09 AM, Elad Moshe <eladm26_at_[hidden]> wrote:
>> If both threads tried to upgrade, you would have a deadlock.
>
> But how is it possible? isn't the upgrade operation atomic?
> if the 2 threads try to upgrade, one will succeed and the other one will
> block until the first thread will unlock.
>

The problem is that upgrade implies that the read lock is not released
before upgrading to the write lock. If both held read locks, and both
tried to upgrade, this would lead to deadlock.

  Brian


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