<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Barrier</title>
	<atom:link href="http://ridiculousfish.com/blog/archives/2007/02/17/barrier/feed/" rel="self" type="application/rss+xml" />
	<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/</link>
	<description>serious code</description>
	<lastBuildDate>Sat, 31 Jul 2010 18:07:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mark Travis</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-1000</link>
		<dc:creator>Mark Travis</dc:creator>
		<pubDate>Fri, 02 Apr 2010 08:53:57 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-1000</guid>
		<description>I think I found an answer to my question--as long as proper fencing is done, such as mfence on x86, prior to the attempted read (LOAD) in thread 2, then the correct value should be referenced by the destination pointer.

Any mutex should do the trick, since I understand that pthread_mutex_lock calls a load-store barrier whenever it&#039;s invoked.</description>
		<content:encoded><![CDATA[<p>I think I found an answer to my question&#8211;as long as proper fencing is done, such as mfence on x86, prior to the attempted read (LOAD) in thread 2, then the correct value should be referenced by the destination pointer.</p>
<p>Any mutex should do the trick, since I understand that pthread_mutex_lock calls a load-store barrier whenever it&#8217;s invoked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Travis</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-999</link>
		<dc:creator>Mark Travis</dc:creator>
		<pubDate>Wed, 31 Mar 2010 06:53:18 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-999</guid>
		<description>I typo&#039;d my above pseudo-code.

thread 1 should read as follows:
payload=5;
srcptr=&payload;

pthread_mutex_lock(&amp;whatevermutex);
queueptr=srcptr;
pthread_mutex_unlock(&amp;whatevermutex);

-------------------------

Thanks</description>
		<content:encoded><![CDATA[<p>I typo&#8217;d my above pseudo-code.</p>
<p>thread 1 should read as follows:<br />
payload=5;<br />
srcptr=&payload;</p>
<p>pthread_mutex_lock(&amp;whatevermutex);<br />
queueptr=srcptr;<br />
pthread_mutex_unlock(&amp;whatevermutex);</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Travis</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-998</link>
		<dc:creator>Mark Travis</dc:creator>
		<pubDate>Wed, 31 Mar 2010 06:44:41 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-998</guid>
		<description>I&#039;m working on a project involving mutexes.  I suspect that I&#039;m doing it wrong, but I can&#039;t seem to force data inconsistency in my own tests.  I&#039;m basically doing message passing of arbitrary data, as follows:

Here&#039;s what I&#039;m basically doing:

int srcpayload, destpayload;
int *srcptr, *queueptr, *destptr;

thread 1:
payload=5;
srcptr=&payload;

pthread_mutex_lock(&amp;whatevermutex);
srcptr=queueptr;
pthread_mutex_unlock(&amp;whatevermutex);

thread 2:
pthread_mutex_lock(&amp;whatevermutex);
destptr=queueptr;
pthread_mutex_unlock(&amp;whatevermutex);

destpayload=*destptr;

--------------------------

What I want is for destpayload to always equal srcpayload.  But since I&#039;m only copying pointers within mutex locks, I&#039;m afraid that it&#039;s possible that the assignment of the payload to the pointer might not be guaranteed to be correct on the destination side.  Is pthreads&#039; mutex logic smart enough to ensure that any assignment of a value to a pointer&#039;s destination is within a proper memory barrier?  My development platform is Linux on amd64, but I want to do the right thing from a portability standpoint.

You seem like a guy (guys?) (gal?) (gal-guys?) who would know this.</description>
		<content:encoded><![CDATA[<p>I&#8217;m working on a project involving mutexes.  I suspect that I&#8217;m doing it wrong, but I can&#8217;t seem to force data inconsistency in my own tests.  I&#8217;m basically doing message passing of arbitrary data, as follows:</p>
<p>Here&#8217;s what I&#8217;m basically doing:</p>
<p>int srcpayload, destpayload;<br />
int *srcptr, *queueptr, *destptr;</p>
<p>thread 1:<br />
payload=5;<br />
srcptr=&payload;</p>
<p>pthread_mutex_lock(&amp;whatevermutex);<br />
srcptr=queueptr;<br />
pthread_mutex_unlock(&amp;whatevermutex);</p>
<p>thread 2:<br />
pthread_mutex_lock(&amp;whatevermutex);<br />
destptr=queueptr;<br />
pthread_mutex_unlock(&amp;whatevermutex);</p>
<p>destpayload=*destptr;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>What I want is for destpayload to always equal srcpayload.  But since I&#8217;m only copying pointers within mutex locks, I&#8217;m afraid that it&#8217;s possible that the assignment of the payload to the pointer might not be guaranteed to be correct on the destination side.  Is pthreads&#8217; mutex logic smart enough to ensure that any assignment of a value to a pointer&#8217;s destination is within a proper memory barrier?  My development platform is Linux on amd64, but I want to do the right thing from a portability standpoint.</p>
<p>You seem like a guy (guys?) (gal?) (gal-guys?) who would know this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dina</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-910</link>
		<dc:creator>dina</dc:creator>
		<pubDate>Tue, 26 Jan 2010 20:10:43 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-910</guid>
		<description>Thanks for this great post. I have been debugging code on multiple platforms and very often need to know what processor is used in the specific platform and what memory synchronizations are missing on that platform(since the bugs are usually caused when the programmer forgets to explicitly add barriers that are not implemented on the platform). Here is the small list I have and would love it if people can add to it:
1. x86, x86-64 : strongly ordered
2. SPARC : Writes are not ordered with respect to reads and writes. 
3. Itanium : Writes are not ordered. Reads (?)
4. HPUX : ?</description>
		<content:encoded><![CDATA[<p>Thanks for this great post. I have been debugging code on multiple platforms and very often need to know what processor is used in the specific platform and what memory synchronizations are missing on that platform(since the bugs are usually caused when the programmer forgets to explicitly add barriers that are not implemented on the platform). Here is the small list I have and would love it if people can add to it:<br />
1. x86, x86-64 : strongly ordered<br />
2. SPARC : Writes are not ordered with respect to reads and writes.<br />
3. Itanium : Writes are not ordered. Reads (?)<br />
4. HPUX : ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nat!</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-818</link>
		<dc:creator>Nat!</dc:creator>
		<pubDate>Wed, 29 Jul 2009 12:13:37 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-818</guid>
		<description>lwsync ? Wasn&#039;t that called isync once ? :)

I thought that an UNLOCK would imply a sync and that therefore the memory barrier would be redundant ? At least that&#039;s how I implemented it (isync in lock, sync in unlock).</description>
		<content:encoded><![CDATA[<p>lwsync ? Wasn&#8217;t that called isync once ? <img src='http://ridiculousfish.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I thought that an UNLOCK would imply a sync and that therefore the memory barrier would be redundant ? At least that&#8217;s how I implemented it (isync in lock, sync in unlock).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Friskywitz</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-743</link>
		<dc:creator>Friskywitz</dc:creator>
		<pubDate>Mon, 11 Jun 2007 00:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-743</guid>
		<description>I got asked several questions pertaining to this exact subject on my third phone interview from Apple Computers.

I said mutex... and should have read this blog first. D&#039;oh!</description>
		<content:encoded><![CDATA[<p>I got asked several questions pertaining to this exact subject on my third phone interview from Apple Computers.</p>
<p>I said mutex&#8230; and should have read this blog first. D&#8217;oh!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Casseres</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-741</link>
		<dc:creator>David Casseres</dc:creator>
		<pubDate>Tue, 13 Mar 2007 04:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-741</guid>
		<description>Helluva post, Fish.  Thanks.</description>
		<content:encoded><![CDATA[<p>Helluva post, Fish.  Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomsci</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-740</link>
		<dc:creator>tomsci</dc:creator>
		<pubDate>Thu, 01 Mar 2007 22:14:29 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-740</guid>
		<description>Cripes, I&#039;m a bit concerned this is the first I recall hearing about memory barriers! I (thought I) knew about out-of-order execution, but the multithreaded implications of that had escaped me.

V interesting post, this is something I&#039;ll file under the category of &quot;Things I hope I never need to use but if I do I now know to go and look it up before even attempting it myself&quot;</description>
		<content:encoded><![CDATA[<p>Cripes, I&#8217;m a bit concerned this is the first I recall hearing about memory barriers! I (thought I) knew about out-of-order execution, but the multithreaded implications of that had escaped me.</p>
<p>V interesting post, this is something I&#8217;ll file under the category of &#8220;Things I hope I never need to use but if I do I now know to go and look it up before even attempting it myself&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asko Kauppi</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-739</link>
		<dc:creator>Asko Kauppi</dc:creator>
		<pubDate>Mon, 26 Feb 2007 20:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-739</guid>
		<description>Having seen the Lua and Io comments, I&#039;ll add to the queue of comments.

Lua does not --as of its standard libraries-- take a stand on how multithreading be made. Coroutines it offers are essentially within-the thread elements, and useful as such.

But with a small addon module to allow chunks of code &#039;thrown&#039; to other Lua states, I can see the language scale easily to 1000s of cores, if so wanted. This development is surely favourable to small footprint languages such as it.

Anyone wanting to have a go at N core Lua, send me a line. :)</description>
		<content:encoded><![CDATA[<p>Having seen the Lua and Io comments, I&#8217;ll add to the queue of comments.</p>
<p>Lua does not &#8211;as of its standard libraries&#8211; take a stand on how multithreading be made. Coroutines it offers are essentially within-the thread elements, and useful as such.</p>
<p>But with a small addon module to allow chunks of code &#8216;thrown&#8217; to other Lua states, I can see the language scale easily to 1000s of cores, if so wanted. This development is surely favourable to small footprint languages such as it.</p>
<p>Anyone wanting to have a go at N core Lua, send me a line. <img src='http://ridiculousfish.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John D.</title>
		<link>http://ridiculousfish.com/blog/archives/2007/02/17/barrier/comment-page-1/#comment-738</link>
		<dc:creator>John D.</dc:creator>
		<pubDate>Mon, 26 Feb 2007 15:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2007/02/17/barrier/#comment-738</guid>
		<description>How about an efficient thread safe static initialization? Would this make a difference?

http://avitzur.hax.com/2006/11/efficient_thread_safe_static_i.html</description>
		<content:encoded><![CDATA[<p>How about an efficient thread safe static initialization? Would this make a difference?</p>
<p><a href="http://avitzur.hax.com/2006/11/efficient_thread_safe_static_i.html" rel="nofollow">http://avitzur.hax.com/2006/11/efficient_thread_safe_static_i.html</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
