|
Boost : |
From: Glenn Schrader (gschrad_at_[hidden])
Date: 2006-12-15 16:56:59
I ran across this bug while running on a 2.6.9 Linux kernel. Since that
kernel version doesn't have native interprocess mutexes and condition
variables the interprocess library uses some emulation code. The x86
verion of the emulated semaphore uses atomic_dec32() from atomic.hpp but
that function wasn't behaving properly. The following change in
oost/interprocess/detail/atomic.hpp made things work properly:
BEFORE:
inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem)
{
unsigned char prev;
asm volatile ("lock; decl %1;\n\t"
"setnz %%al"
: "=a" (prev)
: "m" (*(mem))
: "memory", "cc");
return prev;
}
AFTER:
inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem)
{
boost::uint32_t prev;
// acts like an atomic 'return (*mem)--;'
asm volatile ("movl $-1, %0;\n\t"
"lock; xaddl %0, %1"
: "=r" (prev)
: "m" (*(mem))
: "memory", "cc" );
return prev;
}
-glenn
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk