<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Neural Network Design blog &#187; deadlocks</title>
	<atom:link href="http://janbogaerts.name/index.php/tag/deadlocks/feed/" rel="self" type="application/rss+xml" />
	<link>http://janbogaerts.name</link>
	<description>My take on neural networks, AI and more</description>
	<lastBuildDate>Wed, 28 Jul 2010 18:21:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deadlocks, again</title>
		<link>http://janbogaerts.name/index.php/2010/05/31/deadlocks-again/</link>
		<comments>http://janbogaerts.name/index.php/2010/05/31/deadlocks-again/#comments</comments>
		<pubDate>Mon, 31 May 2010 13:11:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[deadlocks]]></category>

		<guid isPermaLink="false">http://janbogaerts.name/index.php/2010/05/31/deadlocks-again/</guid>
		<description><![CDATA[I just spent the last 3 days chasing down 3 deadlocks that were teaming up against me. Man, I hate deadlocks. They were definitely the biggest obstacles so far in the development process. Simply because their origins are so hard to locate. And that, even though they are always caused by the same type of [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent the last 3 days chasing down 3 deadlocks that were teaming up against me. Man, I hate deadlocks. They were definitely the biggest obstacles so far in the development process. Simply because their origins are so hard to locate. And that, even though they are always caused by the same type of situation: 2 threads intertwining with their locking scheme.</p>
<p>Put into sequence:</p>
<ol>
<li>Thread 1 locks x and continues execution (no waiting) </li>
<li>Thread 2 locks y and continues execution (no waiting) </li>
<li>Thread 1 requests y and waits </li>
<li>Thread 2 requests x and waits,… oeps </li>
</ol>
<p>The most often way to locate this situation is by examining the execution stack of the CPU. But what if you do out of sync locking: the request in function 1 and the release in function 2, without any relationship between the 2 functions. As an example, take the network-core’s lock expression, which is new. This locks the items when the statement is called, but releases them only after all the child statements were called. The interpreter obviously can’t do this in the same function call. </p>
<p> So how do you trace this type of bug? Well, slowly, painfully and with lots of debug code to generate application dumps. here’s the smallest dump that I generated for the core (usually it was several 100 lines longer):</p>
<p> <code>Links in    <br />ID: 7461 ReadCount: 2&#160; WriteCount: 0, Waiting: 0     <br />Links out     <br />ID: 7461 ReadCount: 2&#160; WriteCount: 0, Waiting: 0     <br />Values     <br />ID: 7461 ReadCount: 2&#160; WriteCount: 0, Waiting: 0     <br />Processors     <br />Parents     <br />ID: 7461 ReadCount: 0&#160; WriteCount: 0, Waiting: 2     <br />Children     <br />ID: 7432 ReadCount: 0&#160; WriteCount: 1, Waiting: 0     <br />ID: 7461 ReadCount: 2&#160; WriteCount: 0, Waiting: 0     <br />ID: 7288 ReadCount: 0&#160; WriteCount: 1, Waiting: 0     <br />LockExpressionCounter: 2     <br />Single lock count: 0</code>
<p>Basically, it allows me to check all the locks that are still active (in order of age) when the deadlock occurred. From then it’s simply a matter of figuring out who has the oldest lock and why it wasn’t released. To do this, it’s best to keep track somehow of the threads that do the locking and make certain that they are named, so you can find them again in the execution stack of the debugger.</p>
]]></content:encoded>
			<wfw:commentRss>http://janbogaerts.name/index.php/2010/05/31/deadlocks-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deadlocks and DotNet</title>
		<link>http://janbogaerts.name/index.php/2009/06/28/deadlocks-and-dotnet/</link>
		<comments>http://janbogaerts.name/index.php/2009/06/28/deadlocks-and-dotnet/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 18:56:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[N²D]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[deadlocks]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://janbogaerts.name/index.php/2009/06/28/deadlocks-and-dotnet/</guid>
		<description><![CDATA[Well, that bear (you know, the deadlocks) turned out to be a formidable grizzly. Now, I don’t know about you, but me, when I see a monster like that, I turn around and run… I can assure you, there’s nothing better than a fierce predator on your tail to streamline things.&#160; First to go was [...]]]></description>
			<content:encoded><![CDATA[<p>Well, that bear (you know, <a href="http://janbogaerts.name/index.php/2009/06/03/nnd-011-released/" target="_blank">the deadlocks</a>) turned out to be a formidable grizzly. Now, I don’t know about you, but me, when I see a monster like that, I turn around and run… I can assure you, there’s nothing better than a fierce predator on your tail to streamline things.&#160; First to go was .net’s WeakReference pattern.&#160; This simply couldn’t keep up with the engine (a change that touched every part of the designer: all editors, toolbox, explorer, thesaurus, timers,…). Next was the ReaderWriterLockSlim thingy (used to protect data blocks from corruption), which has a very peculiar definition of slim: you have no idea how many times I have seen my RAM blown up because of a simple integer scan. Lots of other stuff got tuned up or hacked out as well, so the expected update has arrived.</p>
<p>The engine appears to be stabling out, although it is still acting fishy on single core machines, where there are errors I don’t have on my multi core dev system, so I need to move to a different machine to test this out. The designer is also still very much lingering behind the engine when this is processing at full speed, but the UI should remain responsive now.</p>
<p>I have also included an extra demo project called ‘<em>Scanner</em>’. It is able to transform an input stream containing integers, representing characters, into words and numbers (ints and doubles).&#160; This doesn’t seem much, and it isn’t, except that it is doing this using a couple of flows and a general purpose algorithm (processing is still slow, mostly because the UI is trying to catch up).&#160; This was the guts of the older ‘<em>English language definition</em>’ demo, which I have split into 2: the scanner and the language definition, which is no longer able to do any processing (all code removed). It’s an example of a more complex flow.</p>
<p>The scanner demo also has the <em>number scanning problem</em> fixed (numbers longer than 2 came out with multiple results). This appeared to be caused by deleting a couple of neurons to many (in the scanning algorithm).&#160; I had already experienced the dangers of deleting neurons I thought were no longer used, but which were because of the splits. I will probably have to implement some sort of a garbage collection system to clean up unused neurons (but that’s for later).</p>
<p>Anyway, here’s the latest <a href="http://www.janbogaerts.name/files/setup.exe" target="_blank">download</a> (best to remove previous installation before installing this one).</p>
]]></content:encoded>
			<wfw:commentRss>http://janbogaerts.name/index.php/2009/06/28/deadlocks-and-dotnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
