[Ace-users] [ciao-users] DomainApplicationManager_AMI_Impl + Race Condition?

Sowayan, Abdullah (N-DUA) abdullah.sowayan at lmco.com
Wed Oct 24 11:53:00 CDT 2007


CIAO VERSION: 0.6.1 (SVN HEAD Also)

In the following file:
CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_AMI_Impl.h
 
class DomainApplicationManager_Export DomainApplicationManager_AMI_Impl
    : public DomainApplicationManager_AMH_Impl
  {
    /// AMI reply count
    volatile int start_launch_reply_count_;
  };

Why is the counter volatile? Is this an attempt to eliminate race
conditions when the variable is accessed concurrentl? If so, the I'd
have to note that volatile doesn't protect aginst concurrent access, we
should use ACE_Atomic_Op<ACE_Thread_Mutex, long> instead (on certain
platforms, this construct does not incur the price of a mutex lock,
because it expands to assembly code with automic instructions).
 
 
 
These following method implementations (found in the CPP file) use the
counter variable. They should be placed in an inline file (*.inl)
because that's to convention we use in the distribution for non-virtual
methods that only have 1-3 lines of code.
 
void
CIAO::DomainApplicationManager_AMI_Impl::
decrease_start_launch_reply_count ()
{
  --this ->start_launch_reply_count_;
}

int
CIAO::DomainApplicationManager_AMI_Impl::
start_launch_reply_count ()
{
  return this->start_launch_reply_count_;
}

Thanks,
Abdul



More information about the Ace-users mailing list