<?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>Unununium Operating Engine &#187; Research</title>
	<atom:link href="http://unununium.org/?feed=rss2&#038;cat=4" rel="self" type="application/rss+xml" />
	<link>http://unununium.org</link>
	<description>History of an operating system</description>
	<lastBuildDate>Sat, 12 Jun 2010 17:59:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Multi-core, distributed applications, asynchronous services</title>
		<link>http://unununium.org/?p=57</link>
		<comments>http://unununium.org/?p=57#comments</comments>
		<pubDate>Sat, 19 Sep 2009 03:32:36 +0000</pubDate>
		<dc:creator>eks</dc:creator>
				<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://unununium.org/?p=57</guid>
		<description><![CDATA[Wanted to share a few of my latest reads and studies.  First is the programming language &#8220;Axum&#8221; by Microsoft; a good read.  It talks about channels which are used to communicate to services using ports with the ability to define states and transitions, define protocols.  A quick google search should turn you into an &#8220;Axumite&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p>Wanted to share a few of my latest reads and studies.  First is the programming language &#8220;Axum&#8221; by Microsoft; a good read.  It talks about channels which are used to communicate to services using ports with the ability to define states and transitions, define protocols.  A quick google search should turn you into an &#8220;Axumite&#8221;, be careful!</p>
<p>Also came across <a href="http://people.csail.mit.edu/mariacristina/research/lncs.pdf">Reactors</a>, where there are no functions, channels, methods or services.  Only data, states and relations.  Services are provided by requesting a state change.  An interesting read indeed.</p>
<p>How will this all tie in with Unununium? no idea!  But if you put together multicore, OpenCL, CUDA, and all the multiprocessing going on nowadays, you can start formulating an idea.  Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://unununium.org/?feed=rss2&amp;p=57</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A difference in return</title>
		<link>http://unununium.org/?p=13</link>
		<comments>http://unununium.org/?p=13#comments</comments>
		<pubDate>Fri, 31 Jul 2009 13:51:21 +0000</pubDate>
		<dc:creator>eks</dc:creator>
				<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://uuu.sourceforge.net/?p=13</guid>
		<description><![CDATA[I have recently been toying with various methods of returning from a procedure call; how to indicate an error condition or generate some kind of exception.

Here's the scoop; the standard methods used in C and other languages are far from being the most efficient, even the ones we used in past Unununium implementations could be optimized further.  Read more in the article!]]></description>
			<content:encoded><![CDATA[<p>I have recently been toying with various methods of returning from a procedure call; how to indicate an error condition or generate some kind of exception.</p>
<p>Here&#8217;s the scoop; the standard methods used in C and other languages are far from being the most efficient, even the ones we used in past Unununium implementations could be optimized further.  Here&#8217;s how to do it.</p>
<p>First it is important to understand how a cpu is processing instructions. Even before an instruction is executed, a prefetch queue is filled with the next few instructions to execute.  The CPU constantly analyzes if instructions can be piped in parallel and if it can pre-determine the result of a conditional jump prior to reaching that point.  When the CPU takes a wrong guess, this prefetch queue has to be flushed (emptied) causing some delays in execution.</p>
<p>A standard call implementation such as those found in C and typical languages, uses a return value to indicate if an error occured; such as returning -EOF when performing a fread() to indicate the End Of File has been reached.  The program calling the fread procedure (should) always check if the number of bytes read is equal to -EOF or some other error condition; this check takes some cpu cycles to execute and requires a conditional jump which in turn could be wrongly guessed by the CPU and cause a flush of the prefetch queue.</p>
<p>Newer processors and languages allow some flags to be inserted before the conditional jump to indicate what is the most likely outcome to help the processor take the right guess; if something happens and the condition is not matching the typical case the cpu will still have to go thru a prefetch queue flush.</p>
<p><strong>A method exists to alleviate and reduce the number of comparisons required after a function call</strong>; not returning the status of the operation at all!  While this may sound counter productive, it is actually quite efficient and allows for proper error handling.  Here&#8217;s a snippet of assembly code to demonstrate a procedure call:<br />
&#8230;<br />
jmp short .perform_file_read<br />
dd .invalid_file<br />
dd .end_of_file_reached<br />
.perform_file_read:<br />
call read_file<br />
&#8230; use the data, no need to check for errors<br />
.invalid_file:<br />
&#8230; do something; abort?<br />
.end_of_file_reached:<br />
&#8230; terminate the operation</p>
<p>Note that just before we perform a function call we do a inconditional jump, skipping over an &#8220;exception&#8221; table.  An unconditional jump is easily handled by the CPU and will not affect the prefetch queue in any significant manner.  When the call is performed, the &#8216;read_file&#8217; function is able to calculate the location of the exception table based on the address of the return point that was pushed onto the stack.</p>
<p>In the &#8216;read_file&#8217; function, something like this can be done:</p>
<p>&#8230; check if file handle is valid<br />
jc .is_invalid_file_handle<br />
&#8230; check if the end of file has been reached<br />
jc .end_of_file_reached<br />
&#8230; read the requested data<br />
retn<br />
.is_invalid_file_handle:<br />
pop edi<br />
jmp [edi-(5 + 8)]<br />
.end_of_file_reached:<br />
pop edi<br />
jmp [edi-(5 + 4)]</p>
<p>Under normal condition, if the &#8216;file_read&#8217; operation succeeds, it simply return with the data as it normally would, there is no extra cpu cycles used to check if the operation was performed properly and the cost of the entire operation is about the same as with a standard call; with the advantage that the caller still does not need to perform a check!</p>
<p>If an error occured, such as the end of file reached, the CPU will retrieve from the exception table the address where execution should be resumed.  The &#8216;jmp [edi-(5+4)]&#8216; in the example above is the operation of retrieving the return address from the exception table.  When a &#8216;call&#8217; instruction is performed, the return address immediately located after the call is pushed onto the stack.  The encoded form of a near call instruction is 5 bytes long hence the &#8216;5&#8242; in the code above.   By substracting 5 to the return address, we obtain the address of the &#8216;call&#8217; instruction itself.  By substracting another &#8216;4&#8242; we obtain the address where the last exception handler in the table is located, in this case &#8216;.end_of_file_reached&#8217;.</p>
<p>The advantage to the caller is the code will automatically resume where it needs to without having to do any return value comparison.  In a simple malloc() case where the value returned is either NULL (0) or not, <strong>a gain of approximately 5%</strong> (on the call/return code alone) can be seen using the above described method.</p>
<p>Now, I&#8217;d rather call the list of return addresses placed before a call an &#8216;alternative return points&#8217; table rather than an exception table, as the cost associated is much more minimal, and the table has to be specified at every procedure call whereas an exception table is normally set and shared for a block of instructions.</p>
<p>I created page with the sample bootable image which compares performances of both standard and multipath calls <a title="here" href="http://uuu.sourceforge.net/?page_id=16" target="_blank"><span id="sample-permalink">Research: Multipath Calls</span></a></p>
<p>Enjoy the increase in performance!</p>
]]></content:encoded>
			<wfw:commentRss>http://unununium.org/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
