TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

An Introduction to Lock-Free Programming (2012)

83 pointsby bowyakkaover 11 years ago

7 comments

unwindover 11 years ago
I ran into this problem last year, that ordinary mutexes were not working out due to various reasons.<p>Since I do embedded programming, I looked through the ARM manuals and documentation, to see what they have on offer.<p>I ran into the lovely LDREX and STREX instructions, which are just awesome.<p>It was pretty trivial to rewrite e.g. a custom allocator that used to grab a mutex, poke its internal freelists, and release the mutex so that it instead does the poking with <i>LDREX&#x2F;STREX</i>, thus obtaining thread-safety while doing the actual work it wanted to do. Lock-free programming can be beautiful like that.<p>See <a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204f/Cihbghef.html" rel="nofollow">http:&#x2F;&#x2F;infocenter.arm.com&#x2F;help&#x2F;index.jsp?topic=&#x2F;com.arm.doc....</a> for the instruction reference on LDREX&#x2F;STREX.
Patient0over 11 years ago
Oh man, now that lock free programming is such a hot topic I am dreading the code about to be written by people &quot;teaching themselves&quot; about it!<p>&quot;This algorithm is much faster now that I&#x27;ve used some lock free programming techniques I just read about!!!&quot;<p>Code that works correctly on x86 but fails intermittently on another processor. It&#x27;s like a nightmare unfolding...
评论 #7253682 未加载
评论 #7256434 未加载
fit2ruleover 11 years ago
I always found this paper to be quite a good introduction to lock-free techniques:<p><a href="http://www.grame.fr/ressources/publications/LockFree.pdf" rel="nofollow">http:&#x2F;&#x2F;www.grame.fr&#x2F;ressources&#x2F;publications&#x2F;LockFree.pdf</a><p>In the music world, such issues have been solved repeatedly over the years - seems like a little cross-polination would be a good thing ..
taspeotisover 11 years ago
Raymond Chen has a pretty practical guide to lock-free algorithms on his blog.<p><a href="http://social.msdn.microsoft.com/Search/en-US?query=Lock-free%20algorithms&amp;beta=0&amp;rn=The+Old+New+Thing&amp;rq=site:blogs.msdn.com/b/oldnewthing/&amp;ac=5" rel="nofollow">http:&#x2F;&#x2F;social.msdn.microsoft.com&#x2F;Search&#x2F;en-US?query=Lock-fre...</a>
pronover 11 years ago
This is perhaps the place to mention that Java 8 has memory-fence intrinsics (loadFence, storeFence, fullFence in Unsafe)
dschiptsovover 11 years ago
Does side-effect-free programming with persistent data-structures on share-nothing, actor-based architecture, in other words Erlang is qualified to be lock-free?<p>It seems that Haskell also doesn&#x27;t exist.)
评论 #7252612 未加载
评论 #7251924 未加载
评论 #7251898 未加载
评论 #7252231 未加载
CmonDevover 11 years ago
Does unintended infinite message loop count as a dead-lock?
评论 #7254297 未加载