<?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>Silly Science &#187; interrupts</title>
	<atom:link href="http://www.silly-science.co.uk/tag/interrupts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.silly-science.co.uk</link>
	<description>Electronics, Programming and Hacking About</description>
	<lastBuildDate>Tue, 10 Jan 2012 14:21:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XMOS XS-1 Virtual Threads</title>
		<link>http://www.silly-science.co.uk/2010/02/01/xmos-xs-1-virtual-threads/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xmos-xs-1-virtual-threads</link>
		<comments>http://www.silly-science.co.uk/2010/02/01/xmos-xs-1-virtual-threads/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:21:36 +0000</pubDate>
		<dc:creator>The Silly Scientist</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[XCore/XMOS Virtual Threads]]></category>
		<category><![CDATA[context switch]]></category>
		<category><![CDATA[interrupts]]></category>
		<category><![CDATA[xmos]]></category>
		<category><![CDATA[xs-1]]></category>

		<guid isPermaLink="false">http://www.silly-science.co.uk/?p=19</guid>
		<description><![CDATA[The XMOS XS-1 architecture is a multi-threaded architecture. As opposed to normal systems it has a single processor core that can run 8 hardware threads, in real-time with no operating system overhead. But what happens if you run out of threads... 2 answers: either (1) add more cores or (2) virtualize. So I thought I [...]]]></description>
			<content:encoded><![CDATA[<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;counturl=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;count=none&amp;text=XMOS%20XS-1%20Virtual%20Threads" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;counturl=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;count=none&amp;text=XMOS%20XS-1%20Virtual%20Threads" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;title=XMOS%20XS-1%20Virtual%20Threads" id="wpa2a_2">Share/Bookmark</a></p><p>The XMOS XS-1 architecture is a multi-threaded architecture. As opposed to normal systems it has a single processor core that can run 8 hardware threads, in real-time with no operating system overhead. But what happens if you run out of threads... 2 answers: either (1) add more cores or (2) virtualize.</p>
<p>So I thought I would do option (2) as option (1) is too easy in the XMOS architecture and its not very efficient if I want to run 1MIPs processes on a thread that has 50MIPs available. The code for this is freely available from the <a title="XS-1 Virtual Threads sourceforge page" href="http://sourceforge.net/projects/vthreads/" target="_blank">virtual threads sourceforge page</a>.</p>
<p>More information after the break...</p>
<p><span id="more-19"></span></p>
<p>The base of the system is simple <a title="Wikipedia's explanation of context switching" href="http://en.wikipedia.org/wiki/Context_switching" target="_blank">context switching</a> within a single thread - this allows multiple processes to be run on a single thread. The current implementation has only time-slicing for processes and doesn't currently have any way to handle events, ports or channels in a sensible way. Hopefully this soft of thing will be implemented when I spend some more time on the project.</p>
<p>The tricky things to handle are those which I haven't implemented yet... The risk of deadlocking the whole lot of virtual threads is quite high when working with events or waiting for external stimulus. Essentially a carefully implemented library would have to be used to stop this, but still provide the level of functionality you get using the hardware threads.</p>
<p>Its probably fairly safe to assert that the virtual threads will not ever be able to be as functional as the hardware threads.</p>
<p>So, a summary of current features:</p>
<ul>
<li>Able to start an arbitrary number of virtual threads</li>
<li>Simple time sliced context switching of virtual threads</li>
<li>Ability to disable the interrupt for atomic operation</li>
</ul>
<p>Future features:</p>
<ul>
<li>Context switch on external stimulus</li>
<li>Context switch on demand (so a virtual thread can "release" itself from the current hardware thread)</li>
<li>Implementation of access to events, channel comms, hardware</li>
<li>Call to allocate stack space to vthread</li>
<li>More flexible vthread params (ports, chans, etc)</li>
</ul>
<ul></ul>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;counturl=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;count=none&amp;text=XMOS%20XS-1%20Virtual%20Threads" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;counturl=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;count=none&amp;text=XMOS%20XS-1%20Virtual%20Threads" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.silly-science.co.uk%2F2010%2F02%2F01%2Fxmos-xs-1-virtual-threads%2F&amp;title=XMOS%20XS-1%20Virtual%20Threads" id="wpa2a_4">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.silly-science.co.uk/2010/02/01/xmos-xs-1-virtual-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

