Advertisement Advanced thin client solution for Linux, based on Open Source. Mix Windows and Linux applications on the same desktop. V
|
Avoid (one) spinlock deadlockAvoid (one) spinlock deadlockPosted Dec 8, 2005 21:08 UTC (Thu) by mingo (subscriber, #31122)In reply to: Avoid (one) spinlock deadlock by gottlieb Parent article: FOSS.IN: A report
Linux kernel spinlocks have a couple of other twists as well.
#define __raw_spin_lock_string \
or:
repeat:
first we decrement, then we test until the counter has been - if we didnt succeed we keep polling the value without decreasing the value. Note we do not inrease the value back, we just poll the value until the counter goes 1 again. The owner of the lock writes 1 to the lock indiscriminately, thus undoing multiple decrease-by-1 effects, and signalling all waiters to try again. Furthermore, the 'rep;nop' is a 'take it easy' instruction on newer CPUs (it's a NOP on older CPUs) - this saves power and reduces the likelyhood of livelocks too.
(Log in to post comments)
|
Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.