Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] deadlocking race conditionin emulation interprocess_condition.hpp
From: Young, Zachariah L (zachariah.l.young_at_[hidden])
Date: 2009-09-18 13:55:13


I altered the code from this:

      else{
         //Notification occurred, we will lock the checking interprocess_mutex so that
         //if a notify_one notification occurs, only one thread can exit
        //---------------------------------------------------------------
         InternalLock lock;
         if(tout_enabled){
            InternalLock dummy(m_check_mut, abs_time);
            lock = boost::interprocess::move(dummy);
         }
         else{
            InternalLock dummy(m_check_mut);
            lock = boost::interprocess::move(dummy);
         }

         if(!lock){
            timed_out = true;
            unlock_enter_mut = true;
            break;
         }
         //---------------------------------------------------------------
         boost::uint32_t result = detail::atomic_cas32
                        (const_cast<boost::uint32_t*>(&m_command), SLEEP, NOTIFY_ONE);

to this:

      else{
         boost::uint32_t result = detail::atomic_cas32
                        (const_cast<boost::uint32_t*>(&m_command), SLEEP, NOTIFY_ONE);

and I have had no further problems in my tests.

-Zach

-----Original Message-----
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Ion Gaztañaga
Sent: Wednesday, September 16, 2009 11:33 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [Interprocess] deadlocking race conditionin emulation interprocess_condition.hpp

Young, Zachariah L escribió:
> Actually, why lock the m_check_mut at all?
>
> Why not delete that whole thing and remove the m_check_mut from the
class entirely, as it apparently exists only to synchronize the get and set of m_command on line 177 (before any edits), which is an atomic compare-and-set (ie, doesn't need synchronization)?
>
> -Zach

I reach the same conclusion just a minute ago. Could you test your code removing this mutex?

Best,

Ion
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


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