|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-04-09 18:07:19
Rene Rivera:
> Peter Dimov wrote:
>> Can someone with access to ARM please run
>> libs/smart_ptr/test/spinlock_test.cpp and/or take a look at
>> boost/detail/spinlock_gcc_arm.hpp? I've verified that it compiles, but
>> can't
>> run it.
>
> What is the expected behavior? I get no output, no CPU usage, and an
> indefinite running time.
This means a deadlock. The test just locks and unlocks two spinlocks, the
expected behavior is to return immediately. You can try
spinlock_try_test.cpp which might produce some output.
Here's the relevant portion of spinlock_gcc_arm.hpp:
bool try_lock()
{
int r;
__asm__ __volatile__(
"swp %0, %1, [%2]":
"=r"( r ): // outputs
"r"( 1 ), "r"( &v_ ): // inputs
"memory", "cc" );
return r == 0;
}
void lock()
{
for( unsigned k = 0; !try_lock(); ++k )
{
boost::detail::yield( k );
}
}
void unlock()
{
__asm__ __volatile__( "" ::: "memory" );
*const_cast< int volatile* >( &v_ ) = 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk