<?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: RTOS without blocking?</title>
	<atom:link href="http://embeddedgurus.com/state-space/2010/04/rtos-without-blocking/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/state-space/2010/04/rtos-without-blocking/</link>
	<description>A Blog by Miro Samek</description>
	<lastBuildDate>Tue, 08 May 2012 09:20:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Miro Samek</title>
		<link>http://embeddedgurus.com/state-space/2010/04/rtos-without-blocking/comment-page-1/#comment-456</link>
		<dc:creator>Miro Samek</dc:creator>
		<pubDate>Thu, 12 Aug 2010 02:39:28 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/state-space/?p=40#comment-456</guid>
		<description>Thanks for the nudge. It&#039;s about time for the next installment, in which I promised to talk about the challenges of programming without blocking. I plan to explain what you need to sacrifice when you write non-blocking code and why this often leads to &quot;spaghetti&quot; code.

Thanks also for the question about the synchronous request-reply communication. In a traditional sequential programming this is the most basic communication style corresponding to a function call (or perhaps a remote procedure call--RPC). The caller simply blocks until the function returns. Seems clean, but it really sweeps tons of issues under the rug. The question, of course, is what happens between the call and the return.

The event-driven programming paradigm without blocking exposes the in-between. (So yes, the originator of the request indeed returns to the main loop, as *always*.) Without blocking, you explicitly have to do something between an asynchronous request and the asynchronous reply. (I assume that the recipient of the asynchronous request knows that the reply is expected.) So, in real life, the producer of the asynchronous request transitions to a special &quot;waiting-for-reply&quot; state. The behavior in this state could be to ignore all events except the expected reply, but often you will find out that some events in-between should be actually handled. And this is exactly the beauty of event-driven programming. Because you don&#039;t block, you actually *can* handle some events in-between.

In contrast, when you program sequentially, you lose the whole blocked task for the whole duration of the RPC call and you end up inventing another task that is alive and can handle some critical events that arrive in-between. This is how the real mess begins, because now the second task needs to likely access the same data that the first task is operating on, so the whole issue of mutual exclusion comes into play. Mutual exclusion causes more blocking, and so the vicious cycle begins.</description>
		<content:encoded><![CDATA[<p>Thanks for the nudge. It&#8217;s about time for the next installment, in which I promised to talk about the challenges of programming without blocking. I plan to explain what you need to sacrifice when you write non-blocking code and why this often leads to &#8220;spaghetti&#8221; code.</p>
<p>Thanks also for the question about the synchronous request-reply communication. In a traditional sequential programming this is the most basic communication style corresponding to a function call (or perhaps a remote procedure call&#8211;RPC). The caller simply blocks until the function returns. Seems clean, but it really sweeps tons of issues under the rug. The question, of course, is what happens between the call and the return.</p>
<p>The event-driven programming paradigm without blocking exposes the in-between. (So yes, the originator of the request indeed returns to the main loop, as *always*.) Without blocking, you explicitly have to do something between an asynchronous request and the asynchronous reply. (I assume that the recipient of the asynchronous request knows that the reply is expected.) So, in real life, the producer of the asynchronous request transitions to a special &#8220;waiting-for-reply&#8221; state. The behavior in this state could be to ignore all events except the expected reply, but often you will find out that some events in-between should be actually handled. And this is exactly the beauty of event-driven programming. Because you don&#8217;t block, you actually *can* handle some events in-between.</p>
<p>In contrast, when you program sequentially, you lose the whole blocked task for the whole duration of the RPC call and you end up inventing another task that is alive and can handle some critical events that arrive in-between. This is how the real mess begins, because now the second task needs to likely access the same data that the first task is operating on, so the whole issue of mutual exclusion comes into play. Mutual exclusion causes more blocking, and so the vicious cycle begins.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://embeddedgurus.com/state-space/2010/04/rtos-without-blocking/comment-page-1/#comment-452</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Wed, 11 Aug 2010 03:02:27 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/state-space/?p=40#comment-452</guid>
		<description>I&#039;m looking forward to the next post in the series, hope you haven&#039;t forgotten about it. 

The generic task_routine you present seems very elegant, but I&#039;m curious to know how you handle the case when the event handler needs to query another task, i.e. if it cannot continue processing until it gets a reply to a message. 
It could return back to the main event loop to wait for the reply but then that would require saving state somewhere and adding another event type for the event handler to handle, which could easily get very messy. 

Do you have any tips for this kind of situation?</description>
		<content:encoded><![CDATA[<p>I&#8217;m looking forward to the next post in the series, hope you haven&#8217;t forgotten about it. </p>
<p>The generic task_routine you present seems very elegant, but I&#8217;m curious to know how you handle the case when the event handler needs to query another task, i.e. if it cannot continue processing until it gets a reply to a message.<br />
It could return back to the main event loop to wait for the reply but then that would require saving state somewhere and adding another event type for the event handler to handle, which could easily get very messy. </p>
<p>Do you have any tips for this kind of situation?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yoquan</title>
		<link>http://embeddedgurus.com/state-space/2010/04/rtos-without-blocking/comment-page-1/#comment-432</link>
		<dc:creator>Yoquan</dc:creator>
		<pubDate>Fri, 06 Aug 2010 14:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://embeddedgurus.com/state-space/?p=40#comment-432</guid>
		<description>Hi Miro,

I just start working for nearly 2 years for a small company outsourcing embedded (mobile) software.  I&#039;ve done my Master degree in Quantum optics, and have been still in love with QM. That why I was so excited when found out you and your book.  I also have a deep belief in the meaning of the &quot;State&quot; concept even in this old-fashion industry. 

I&#039;m planning to learn your idea to my best and try to apply it for making a simple hypervisor.  I&#039;m not sure whether it is possible. But it&#039;s a long road ahead of my career, I have a lot of time to try it :)</description>
		<content:encoded><![CDATA[<p>Hi Miro,</p>
<p>I just start working for nearly 2 years for a small company outsourcing embedded (mobile) software.  I&#8217;ve done my Master degree in Quantum optics, and have been still in love with QM. That why I was so excited when found out you and your book.  I also have a deep belief in the meaning of the &#8220;State&#8221; concept even in this old-fashion industry. </p>
<p>I&#8217;m planning to learn your idea to my best and try to apply it for making a simple hypervisor.  I&#8217;m not sure whether it is possible. But it&#8217;s a long road ahead of my career, I have a lot of time to try it <img src='http://embeddedgurus.com/state-space/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

