
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.

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. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

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; }

Peter Dimov wrote:
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.
OK, I made it output which code it's going to execute. And it only gets as far as the first call: ==== coda$ ./spinlock_test // sp.lock(); // boost::detail::yield( 0 ); // boost::detail::yield( 1 ); // boost::detail::yield( 2 ); // boost::detail::yield( 3 ); // boost::detail::yield( 4 ); [and so on...] ====
Here's the relevant portion of spinlock_gcc_arm.hpp:
bool try_lock() [...]
That would help if I knew ARM assembly ;-) -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Peter Dimov wrote:
What happens when you change...
bool try_lock() { int r;
__asm__ __volatile__( "swp %0, %1, [%2]": "=r"( r ): // outputs
... this line to
"=&r"( r ): // outputs
Bingo! ==== coda$ ./spinlock_test // sp.lock(); // sp2.lock(); // sp.unlock(); // sp2.unlock(); // scoped_lock... // ...scoped_lock coda$ ==== -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera:
Peter Dimov wrote:
What happens when you change...
bool try_lock() { int r;
__asm__ __volatile__( "swp %0, %1, [%2]": "=r"( r ): // outputs
... this line to
"=&r"( r ): // outputs
Bingo!
Thanks, fixed in SVN. Apparently, the swp instruction doesn't like being given the same register twice. Does spinlock_try_test.cpp pass as well?

Peter Dimov wrote:
Rene Rivera:
Peter Dimov wrote:
What happens when you change...
bool try_lock() { int r;
__asm__ __volatile__( "swp %0, %1, [%2]": "=r"( r ): // outputs ... this line to
"=&r"( r ): // outputs Bingo!
Thanks, fixed in SVN. Apparently, the swp instruction doesn't like being given the same register twice. Does spinlock_try_test.cpp pass as well?
I'll find out in a few hours... Going to dinner now :-) -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera wrote:
Peter Dimov wrote:
Thanks, fixed in SVN. Apparently, the swp instruction doesn't like being given the same register twice. Does spinlock_try_test.cpp pass as well?
I'll find out in a few hours... Going to dinner now :-)
Seems to work: ==== coda$ ./spinlock_try_test No errors detected. coda$ echo $? 0 coda$ ==== -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Hi there, I have recently found a nice solution for the missing Test and Set on ARM < ARMv6: http://0pointer.de/blog/projects/atomic-rt.html There is a linux only (maybe 2.6 only) solution. kind regards Andreas Pokorny

Rene Rivera wrote:
Rene Rivera wrote:
Peter Dimov wrote:
Thanks, fixed in SVN. Apparently, the swp instruction doesn't like being given the same register twice. Does spinlock_try_test.cpp pass as well? I'll find out in a few hours... Going to dinner now :-)
Seems to work:
==== coda$ ./spinlock_try_test No errors detected. coda$ echo $? 0 coda$ ====
Peter, Following up on the above... There are now some minimal test results for smart_ptr, and a few other libs, in the trunk result pages. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org (msn) - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail

Rene Rivera:
coda$ ./spinlock_try_test No errors detected. coda$ echo $? 0 coda$ ====
Peter,
Following up on the above... There are now some minimal test results for smart_ptr, and a few other libs, in the trunk result pages.
Yes, I saw them appear the other day, thanks. shared_ptr on GCC/ARM now uses the spinlock by default, which seems to work fine. You do have some kind of a problem with the exception handling though. Catch clauses do not seem to work.
participants (3)
-
Andreas Pokorny
-
Peter Dimov
-
Rene Rivera