<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Badger Blog</title>
	<atom:link href="http://badgerati.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://badgerati.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 03 Jun 2009 22:21:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='badgerati.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/97ffdb1aa39e0acbdf7df3624316781c?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The Badger Blog</title>
		<link>http://badgerati.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://badgerati.wordpress.com/osd.xml" title="The Badger Blog" />
		<item>
		<title>CSKH &#8211; Definition of a Distributed System</title>
		<link>http://badgerati.wordpress.com/2009/06/03/cskh-definition-of-a-distributed-system/</link>
		<comments>http://badgerati.wordpress.com/2009/06/03/cskh-definition-of-a-distributed-system/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 22:21:30 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[CS Know How]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=535</guid>
		<description><![CDATA[What is a Distributed System?
Put quite simply, a distributed system is a number of pieces of hardware and software that communicate with each other, but use different processors. They can communicate over a network such as Local Area Network (LAN), or the Internet (WAN). Distributed systems are subject to a number of problems, however, such [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=535&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>What is a Distributed System?</h2>
<p>Put quite simply, a distributed system is a number of pieces of hardware and software that communicate with each other, but use different processors. They can communicate over a network such as Local Area Network (LAN), or the Internet (WAN). Distributed systems are subject to a number of problems, however, such as variable latency – which is when 2 identical messages sent between 2 identical computers may now take the same amount of time to arrive. This can cause unpredictable failures, such as messages not being sent.</p>
<p> </p>
<h2>Definition of a Distributed System</h2>
<p>The definition of a <em>distributed system</em> is one which has <strong>independent</strong><strong> </strong>and <strong>self-sufficient</strong><strong> </strong>– often <strong>heterogeneous</strong> or<strong> </strong><strong>autonomous</strong><strong> </strong>–<strong> </strong><strong>spatially-separated</strong> components which must us a common <strong>interconnect</strong> to exchange information in order to coordinate information, and to make the whole system appear to its user as a single coherent system.</p>
<p> </p>
<p>            To further this more a <em>distributed system</em> is the result of collaboration between <strong>separate,</strong><strong> </strong><strong>independent</strong><strong> </strong><strong>processes</strong>. In order for separate, independent processes to collaborate, then they must interact.</p>
<p>            If this interaction is by means of message passing then each component must be aware of the mechanisms for <strong>interprocess</strong><strong> </strong><strong>communication</strong> <strong>(IPC)</strong>, as well as the protocols for using these mechanisms.</p>
<p> </p>
<p>This definition is described over a number of posts under the category “Distributed Systems”: <a href="http://badgerati.wordpress.com/category/revision/distributed-systems/">http://badgerati.wordpress.com/category/revision/distributed-systems/</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/535/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/535/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/535/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/535/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/535/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/535/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/535/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/535/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/535/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/535/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=535&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/06/03/cskh-definition-of-a-distributed-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>
	</item>
		<item>
		<title>CSKH &#8211; Mediated Message Exchange (MME)</title>
		<link>http://badgerati.wordpress.com/2009/06/03/cskh-mediated-message-exchange-mme/</link>
		<comments>http://badgerati.wordpress.com/2009/06/03/cskh-mediated-message-exchange-mme/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:37:59 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[CS Know How]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=529</guid>
		<description><![CDATA[Mediated Message Exchange (MME)
 This is an architecture that arises from Distributed Systems architectures and event synchronization. Within an MME, Interprocess Communication (IPC) is not direct, unlike in Direct Message Exchange (DME) Architecture. This means that processes do not send and receive data directly; this is because they first have to communicate directly with a Middleware [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=529&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Mediated Message Exchange (MME)</h2>
<p> This is an architecture that arises from Distributed Systems architectures and event synchronization. Within an MME, Interprocess Communication (IPC) is not direct, unlike in Direct Message Exchange (DME) Architecture. This means that processes do not send and receive data directly; this is because they first have to communicate directly with a Middleware component.</p>
<p>This form of Middleware is referred to as Message-Oriented Middleware – or MOM for short.</p>
<p> </p>
<p>The MOM component is interposed between clients and it is used to mediate IPC. It also allows event synchronization to be decoupled in time without threading or forking.</p>
<p> </p>
<p> </p>
<div id="attachment_267" class="wp-caption alignnone" style="width: 409px"><img class="size-full wp-image-267 " title="mom" src="http://badgerati.files.wordpress.com/2009/05/mom.png?w=399&#038;h=115" alt="Message-Oriented Middleware" width="399" height="115" /><p class="wp-caption-text">Message-Oriented Middleware</p></div>
<p> </p>
<p> </p>
<p>Messages are sent to the MOM in a queue, which then sends the messages to the required receiver client. If a message comes from one source client and goes to one destination client, then the MME Architecture is said to be Point-to-Point.</p>
<p> </p>
<p>In some MME Architectures, a message can go to more than one destination client, such as publish-subscribe systems.</p>
<p> </p>
<p>In this case, a client <strong>subscribe</strong>s with the <strong>MOM</strong> expressing an interest in certain events from other clients. Then, when a client <strong>publish</strong>es an event with the <strong>MOM</strong>, it notifies the subscribing clients.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/529/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=529&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/06/03/cskh-mediated-message-exchange-mme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/mom.png" medium="image">
			<media:title type="html">mom</media:title>
		</media:content>
	</item>
		<item>
		<title>CSKH &#8211; Direct Message Exchange (DME)</title>
		<link>http://badgerati.wordpress.com/2009/06/03/cskh-direct-message-exchange-dme/</link>
		<comments>http://badgerati.wordpress.com/2009/06/03/cskh-direct-message-exchange-dme/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:18:44 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[CS Know How]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=523</guid>
		<description><![CDATA[Direct Messaging Exchange (DME)
            This is an architecture that arises from Distributed Systems architectures and event synchronization. Because of the way DME’s are built, Interprocess Communication (IPC) follows a very simple pattern.
 
In DME Architectures, a process must be in a position to receive a message/data from some other process.  Therefore, a process can send data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=523&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Direct Messaging Exchange (DME)</h2>
<p>            This is an architecture that arises from Distributed Systems architectures and event synchronization. Because of the way DME’s are built, Interprocess Communication (IPC) follows a very simple pattern.</p>
<p> </p>
<p>In DME Architectures, a process must be in a position to receive a message/data from some other process.  Therefore, a process can send data to some other process, and when this other process receives said data, it may process the sent data, and then send a response message to the process the data initially came from.</p>
<p> </p>
<ol>
<li><em>P<sub>2</sub> </em>is in the receiving state</li>
<li><em>P<sub>1</sub> </em>sends some data <em>D<sub>1</sub></em> to process <em>P<sub>2</sub></em></li>
<li><em>P<sub>1</sub> </em>is now in the receiving state</li>
<li><em>P<sub>2</sub> </em>receives data <em>D<sub>1</sub></em> and processes it</li>
<li><em>P<sub>2</sub> </em>now sends a response message <em>D<sub>2</sub></em> back to process <em>P<sub>1</sub></em></li>
<li>Repeat      steps 1-6</li>
</ol>
<p> </p>
<p>Because of the way that a DME Architecture is set up, the event synchronization is unmediated. For example, the interacting processes must themselves take case of synchronizing the events in order to send the data. Because of this, there a 2 types of DME’s:</p>
<p> </p>
<ul>
<li>Asymmetric</li>
<li>Symmetric</li>
</ul>
<p> </p>
<h2>Asymmetric DME</h2>
<p>In an Asymmetric DME, event synchronization is a lot simpler, because one process &#8211; say the servers – can just wait for requests from some other processes – say clients. The clients also have a function, once they send a message; they must wait for a response from the server.</p>
<p>Asymmetric DME’s also allow a process to be assigned a special role; for example, a process could act as a server to other processes acting as clients.</p>
<p> </p>
<p>So, we say that a client sends a request message to the server, and then waits in receiving mode. However, the server has been waiting in receiving mode for a request message from the client. So, on receiving this message, the server processes it and sends the client a response message.</p>
<p> </p>
<p>Because of the structure of an Asymmetric DME, it is common for the server to take on heavier loads. However, this requires balancing, and can prevent scaling.</p>
<p> </p>
<p>Typical examples of daily used Asymmetric DME’s are the Web and Email.</p>
<p> </p>
<p> </p>
<div id="attachment_265" class="wp-caption alignnone" style="width: 338px"><img class="size-full wp-image-265 " title="aymm" src="http://badgerati.files.wordpress.com/2009/05/aymm.png?w=328&#038;h=285" alt="asymmetric intefconnect" width="328" height="285" /><p class="wp-caption-text">asymmetric intefconnect</p></div>
<p> </p>
<h2>Symmetric DME</h2>
<p>In a <strong>symmetric DME</strong> the problem is much less acute. No special role is assigned to any process in a <strong>symmetric DME</strong>, unlike in an <strong>asymmetric DME</strong>. This time processes are <strong>peers</strong>, hence the term <strong>peer-to-peer (P2P) architecture</strong><strong>. </strong><strong>P2P architectures</strong> are seen as leading naturally to balanced loads, and graceful scaling.</p>
<p> </p>
<p>No process simply waits for a request message in order to respond, and no process simply makes a request message and waits for a response. This is why <strong>event synchronization</strong> is less simple in a <strong>symmetric DME</strong><strong>.</strong></p>
<p> </p>
<p>An example is <em>Skype:</em></p>
<ul>
<li><em>Skype</em> is a <strong>P2P</strong> VoIP (Voice over IP) application</li>
<li><em>Skype</em> uses <strong>super-peers</strong> which are basically just peers which take on a specialized role, in order to form a hierarchy amongst peers.</li>
<li><em>Skype</em> is therefore not a pure <strong>symmetric</strong><strong> </strong><strong>DME</strong>.</li>
</ul>
<p> </p>
<p> </p>
<div id="attachment_266" class="wp-caption alignnone" style="width: 295px"><img class="size-full wp-image-266 " title="symm" src="http://badgerati.files.wordpress.com/2009/05/symm.png?w=285&#038;h=222" alt="Symmetric Interconnect" width="285" height="222" /><p class="wp-caption-text">Symmetric Interconnect</p></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/523/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=523&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/06/03/cskh-direct-message-exchange-dme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/aymm.png" medium="image">
			<media:title type="html">aymm</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/symm.png" medium="image">
			<media:title type="html">symm</media:title>
		</media:content>
	</item>
		<item>
		<title>Exam Date Fail&#8230;</title>
		<link>http://badgerati.wordpress.com/2009/06/01/exam-date-fail/</link>
		<comments>http://badgerati.wordpress.com/2009/06/01/exam-date-fail/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 15:35:39 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Revision]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=518</guid>
		<description><![CDATA[Ive heard of a teacher getting the date wrong on the whiteboard wrong once in a while. But an examiner getting it wrong? This just takes the biscuit&#8230;

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=518&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ive heard of a teacher getting the date wrong on the whiteboard wrong once in a while. But an examiner getting it wrong? This just takes the biscuit&#8230;</p>
<p><img class="alignnone size-full wp-image-519" title="DSC00200" src="http://badgerati.files.wordpress.com/2009/06/dsc00200.jpg?w=570&#038;h=427" alt="DSC00200" width="570" height="427" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/518/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=518&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/06/01/exam-date-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/06/dsc00200.jpg" medium="image">
			<media:title type="html">DSC00200</media:title>
		</media:content>
	</item>
		<item>
		<title>COMP10020 &#8211; Discrete Maths &#8211; Induction (part 2)</title>
		<link>http://badgerati.wordpress.com/2009/05/31/comp10020-discrete-maths-induction-part-2/</link>
		<comments>http://badgerati.wordpress.com/2009/05/31/comp10020-discrete-maths-induction-part-2/#comments</comments>
		<pubDate>Sun, 31 May 2009 11:41:39 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Discrete Maths]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=511</guid>
		<description><![CDATA[A better Example
Let’s take a look at another example, this time lets use:
n          
∑ i2   =     (n(n+1)(2n+1)) / 6
i=0            
 
Where we have:
 
                n
L(n) =    ∑ i2                          and                        R(n) =    (n(n+1)(2n+1)) / 6
                i=0
 
For now I will skip the base case. However, do note that when n=0 for the base case, L(0)=R(0), so that the base [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=511&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>A better Example</h2>
<p>Let’s take a look at another example, this time lets use:</p>
<p><sub>n</sub>          </p>
<p><strong>∑ </strong>i<sup>2</sup>   =     (n(n+1)(2n+1)) / 6</p>
<p><strong><sup>i=0</sup></strong><strong>            </strong></p>
<p><strong> </strong></p>
<p>Where we have:</p>
<p> </p>
<p>                <sub>n</sub></p>
<p>L(n) =    <strong>∑ </strong>i<sup>2</sup>                          and                        R(n) =    (n(n+1)(2n+1)) / 6</p>
<p>                <sup>i=0</sup></p>
<p> </p>
<p>For now I will skip the base case. However, do note that when n=0 for the base case, L(0)=R(0), so that the base case is true. As for the step cases, we have:</p>
<p> </p>
<ul>
<li><strong>∑ </strong>i<sup>2</sup>       =  <strong>∑ </strong>(n+1)<sup>2</sup></li>
</ul>
<p> </p>
<p>Once this is done, we then need to move everything next to the ‘∑’ onto the right hand side. So we get this:</p>
<p> </p>
<ul>
<li>before we move we have:<br />
           R(n)     =          (n(n+1)(2n+1)) / 6</li>
<li>Once the ‘i’ has be moved over, then R(n) becomes R(n+1), and we have:<br />
           R(n+1) =          [(n(n+1)(2n+1)) / 6]   +  (n+1)<sup>2</sup></li>
</ul>
<p><sup> </sup></p>
<p>Once we have this, it is just simple arithmetic:</p>
<p> </p>
<p>(1) = [(n(n+1)(2n+1)) / 6]  +  (n+1)<sup>2</sup></p>
<p>(2) = [(n(n+1)(2n+1)) / 6]  +  [6(n+1)<sup>2</sup> / 6]               <em>make both have same denominator.</em></p>
<p>(3) = (n(n+1)(2n+1) + 6(n+1)<sup>2</sup>) / 6                             <em>bring both together</em></p>
<p>(4) = ((n+1)(n+2)(2n+3)) / 6                                  </p>
<p>(5) = R(n+1)</p>
<p> </p>
<p>As from before, step (4) requires you to expand the brackets from step (3), the fractionise the whole lot to obtain <strong>(n+1)(n+2)(2n+3)</strong>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/511/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=511&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/05/31/comp10020-discrete-maths-induction-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>
	</item>
		<item>
		<title>COMP10020 &#8211; Discrete Maths &#8211; Induction (part 1)</title>
		<link>http://badgerati.wordpress.com/2009/05/31/comp10020-discrete-maths-induction-part-1/</link>
		<comments>http://badgerati.wordpress.com/2009/05/31/comp10020-discrete-maths-induction-part-1/#comments</comments>
		<pubDate>Sun, 31 May 2009 11:03:08 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Discrete Maths]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=505</guid>
		<description><![CDATA[[ A = for all.    E = there exists ]
 
The Principles of Induction
Firstly, welcome to Induction. The one thing in Discrete Maths that I hear a heck of a lot of people complaining about! – So don’t worry, you’re not the only one  
 
Here I shall attempt – attempt being the key word – [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=505&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>[ <strong><em>A</em></strong> = for all.    <strong><em>E</em></strong> = there exists ]</p>
<p><strong> </strong></p>
<h2>The Principles of Induction</h2>
<p>Firstly, welcome to Induction. The one thing in Discrete Maths that I hear a heck of a lot of people complaining about! – So don’t worry, you’re not the only one <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p> </p>
<p>Here I shall <em>attempt</em> – <em>attempt </em>being the key word – to make induction make a lot more sense to you.</p>
<p> </p>
<p> </p>
<p>OK, so let’s say we have a set, ‘X’ of natural numbers:</p>
<p> </p>
<ul>
<li>X = {1, 2, 3, 4…}</li>
</ul>
<p> </p>
<p>The first thing we need to understand about induction is that we have 2 cases.</p>
<p> </p>
<ul>
<li>First there is the ‘base’ case which is the lowest value of say ‘n’ possible, that makes a given equation true – usually 0.</li>
<li>Secondly we have the ‘step’ case. This states that if the equation is true for ‘n’, then theoretically it must be true for ‘n+1’.</li>
</ul>
<p> </p>
<p>We can show this relation with set theory, so:</p>
<p> </p>
<ul>
<li>Base case:      0 Є X</li>
<li>Step case:       <strong><em>A</em></strong>n Є N, n Є X  =&gt;  (n+1) Є N</li>
</ul>
<p> </p>
<p>Let’s say that we have the some function <em>P</em>(n). The base and step cases for this function would be:</p>
<p> </p>
<ul>
<li>Base:  <em>P</em>(0) = true</li>
<li>Step:   <strong><em>A</em></strong>n Є N, if <em>P</em>(n)=true then so must <em>P</em>(n+1)</li>
</ul>
<p> </p>
<h2>Induction</h2>
<p>Let’s now have a proper example on how we do induction. Say for example you have the following summation – and you are given the answer:</p>
<p><sub>n</sub>          </p>
<p><strong>∑ </strong>i   =     ( n(n+1) ) / 2</p>
<p><strong><sup>i=0</sup></strong><strong>                 </strong></p>
<p><strong> </strong></p>
<p>Now that we have this, we need to split up the formula:</p>
<p>                <sub>n</sub></p>
<p>L(n) =    <strong>∑ </strong>i                            and                        R(n) =    ( (n(n+1) ) / 2</p>
<p>                <sup>i=0</sup></p>
<p> </p>
<p>For this, we need to say that <strong><em>A</em></strong>n Є N, then L(n)=R(n).</p>
<p>For this summation, the Base case is clearly 0. so is it true that L(0)=R(0)? Let’s find out:</p>
<p> </p>
<ul>
<li>When i=0 in      <strong>∑ </strong>i, then it is quite obvious that <strong>∑ </strong>i=0. Therefore L(0)=0</li>
<li>In the case if R(0), we have:                = ( (n(n+1)) / 2<br />
                = ( (0(0+1)) / 2<br />
                = (0(1)) / 2<br />
                = 0 / 2<br />
                = 0 </p>
<p>Therefore, R(0)=0 as well. So:</li>
<li>L(0) = R(0) is true. And therefore the Base case      is true.</li>
</ul>
<p> </p>
<p> </p>
<p>Now we need to move onto the Step case part. This part is a little trickier to explain, so you’ll have to bear with me on this…</p>
<p>We know that L(n)=R(n), however, we need to prove that L(n+1)=R(n+1).</p>
<p> </p>
<p>A quick way to do this, is that when we state L(n+1), change all the ‘i’ next to the ‘∑’ to ‘n+1’. So in this case we have: (better example later)</p>
<p> </p>
<ul>
<li><strong>∑ </strong>i  =  <strong>∑ </strong>(n+1)</li>
</ul>
<p> </p>
<p>Once this is done, we then need to move everything next to the ‘∑’ onto the right hand side. So we get this:</p>
<p> </p>
<ul>
<li>before we move we have:<br />
           R(n)     =          (n(n+1)) / 2</li>
<li>Once the ‘i’ has be moved over, then R(n) becomes R(n+1), and we have:<br />
           R(n+1) =          [(n(n+1)) / 2]   +  (n+1)</li>
</ul>
<p> </p>
<p>Once we have this, it is just simple arithmetic:</p>
<p> </p>
<p>(1) = [(n(n+1)) / 2]  +  (n+1)</p>
<p>(2) = [(n(n+1)) / 2]  +  [2(n+1) / 2]             <em>make both have same denominator.</em></p>
<p>(3) = (n(n+1) + 2(n+1)) / 2                         <em>bring both together</em></p>
<p>(4) = ((n+1)(n+2)) / 2                                 <em>This step will be explained further in the sec</em></p>
<p>(5) = R(n+1)            <em>this step requires some common sense really. Go back to R(n),                                      then sub in (n+1) into all n, from (n(n+1)) / 2. What do you get?</em></p>
<p><em>                              Exactly <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  , you should hopefully end up with ((n+1)(n+2)) / 2. if not,                              here:</em></p>
<p><em> </em></p>
<p><em>                              (n(n+1)) / 2</em></p>
<p><em>                              ( <strong>(n+1)</strong> (<strong>(n+1)</strong>+1) ) / 2</em></p>
<p><em>                              ((n+1)(n+2)) / 2</em></p>
<p><em> </em></p>
<p>OK then, so, step (4). For this step, you need to expand the brackets. Once that is do you should have: <strong>n<sup>2</sup>+3n+2</strong>. Then fractionise this to get: <strong>(n+1)(n+2)</strong>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/505/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=505&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/05/31/comp10020-discrete-maths-induction-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>
	</item>
		<item>
		<title>COMP10052 &#8211; Distributed Systems &#8211; Bully Algorithm</title>
		<link>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-bully-algorithm/</link>
		<comments>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-bully-algorithm/#comments</comments>
		<pubDate>Wed, 27 May 2009 17:49:09 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Distributed Systems]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=484</guid>
		<description><![CDATA[Let’s assume that we have 7 nodes:
 

 
At this current moment in time, node ‘7’ is the coordinator, because it is the highest numbered node. But then node ‘7’ leaves, so who is now the coordinator? Lets say node ‘4’ decides it wants to be the coordinator, then we have:
 

 
Here, node ‘4’ has sent a ELECTION [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=484&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Let’s assume that we have 7 nodes:</p>
<p> </p>
<p><img class="alignnone size-full wp-image-485" title="ini7" src="http://badgerati.files.wordpress.com/2009/05/ini7.png?w=399&#038;h=54" alt="ini7" width="399" height="54" /></p>
<p> </p>
<p>At this current moment in time, node ‘7’ is the coordinator, because it is the highest numbered node. But then node ‘7’ leaves, so who is now the coordinator? Lets say node ‘4’ decides it wants to be the coordinator, then we have:</p>
<p> </p>
<p><img class="alignnone size-full wp-image-486" title="ele1" src="http://badgerati.files.wordpress.com/2009/05/ele1.png?w=275&#038;h=242" alt="ele1" width="275" height="242" /></p>
<p> </p>
<p>Here, node ‘4’ has sent a ELECTION to nodes ‘5’, ‘6’ and ‘7’, this is because none of the nodes know that node ‘7’ has left yet. In this case, node ‘7’ cannot reply, yet, nodes ‘5’, and ‘6’ are still here, so they reply to ‘4’ that they are still here:</p>
<p> </p>
<p><img class="alignnone size-full wp-image-492" title="ele2" src="http://badgerati.files.wordpress.com/2009/05/ele21.png?w=275&#038;h=242" alt="ele2" width="275" height="242" /></p>
<p> </p>
<p>Now we have nodes ‘5’ and ‘6’ sending out elections. In this case, node ‘5’ sends an election to node ‘6’ and ‘7’. Whereas node ‘6’ just sends an election to node ‘7’:</p>
<p> </p>
<p><img class="alignnone size-full wp-image-494" title="ele3" src="http://badgerati.files.wordpress.com/2009/05/ele31.png?w=275&#038;h=242" alt="ele3" width="275" height="242" /></p>
<p> </p>
<p>Now, since node ‘6’ is still here, then node ‘6’ tells node ‘5’ that it is still here:</p>
<p> </p>
<p><img class="alignnone size-full wp-image-498" title="ele4" src="http://badgerati.files.wordpress.com/2009/05/ele43.png?w=361&#038;h=242" alt="ele4" width="361" height="242" /></p>
<p> </p>
<p>Finally, since node ‘7’ has not replied to node ‘6’, this implies that node ‘7’ no longer exists, meaning that node ‘6’ is the new coordinator. So node ‘6’ tells all the other nodes:</p>
<p> </p>
<p><img class="alignnone size-full wp-image-500" title="elefin" src="http://badgerati.files.wordpress.com/2009/05/elefin2.png?w=375&#038;h=242" alt="elefin" width="375" height="242" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/484/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/484/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/484/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/484/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/484/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/484/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/484/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/484/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/484/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/484/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=484&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-bully-algorithm/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/ini7.png" medium="image">
			<media:title type="html">ini7</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/ele1.png" medium="image">
			<media:title type="html">ele1</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/ele21.png" medium="image">
			<media:title type="html">ele2</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/ele31.png" medium="image">
			<media:title type="html">ele3</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/ele43.png" medium="image">
			<media:title type="html">ele4</media:title>
		</media:content>

		<media:content url="http://badgerati.files.wordpress.com/2009/05/elefin2.png" medium="image">
			<media:title type="html">elefin</media:title>
		</media:content>
	</item>
		<item>
		<title>COMP10052 &#8211; Distributed Systems &#8211; Logical Clocks and Processes</title>
		<link>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-logical-clocks-and-processes/</link>
		<comments>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-logical-clocks-and-processes/#comments</comments>
		<pubDate>Wed, 27 May 2009 17:42:18 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Distributed Systems]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=479</guid>
		<description><![CDATA[Fat Clients
A fat client is a client in a client-server architecture network which typically provides rich functionality independently of the central server. Originally known as just ‘client’ or ‘thick client’, the name is contrasted to thin client, which describes a computer heavily dependant on a servers applications.
 
Thin Clients
A thin client is a client computer or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=479&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Fat Clients</h2>
<p>A fat client is a client in a client-server architecture network which typically provides rich functionality independently of the central server. Originally known as just ‘client’ or ‘thick client’, the name is contrasted to <strong>thin client</strong>, which describes a computer heavily dependant on a servers applications.</p>
<p> </p>
<h2>Thin Clients</h2>
<p>A thin client is a client computer or client software in a client-server architecture network which depends primarily on the central server for processing activities, and mainly focuses on conveying input and output between the user and the remote server. In contrast, a thick or <strong>fat client</strong> does as much processing as possible and passes only data for communications and storage to the server.</p>
<p> </p>
<h2>Logical Clocks</h2>
<p>Let’s say we have a logical clock, LC<sub>i</sub> for each processor. In this case, when ever an event happens, we shall increment LC<sub>i</sub>.</p>
<p>If a processor, X, sends a message to processor, Y, then processor X will also send LC<sub>X</sub>, which is that processors logical clock.</p>
<p>When processor Y receives this message, then we do:</p>
<p> </p>
<p><strong>If LC<sub>Y</sub> &lt; (LC<sub>X</sub> + 1):</strong></p>
<p><strong>            LC<sub>Y</sub> = LC<sub>X</sub> + 1</strong></p>
<p><strong> </strong></p>
<p>In order to update processor Y’s logical clock.</p>
<p> </p>
<h2>Lamport Clocks</h2>
<p>Let’s now say that we have a processor ‘A’ and ‘B’. There are a few things we can say:</p>
<p> </p>
<ul>
<li>If A precedes (happens before) B, then we can write <strong>A &#8211;&gt; B</strong></li>
<li>If A and B are concurrent events, then sadly we can’t say anything about their ordering.</li>
</ul>
<p> </p>
<p>If <strong>A &#8211;&gt; B </strong>is true, then it must also be true that LC<sub>A</sub> &lt; LC<sub>B</sub>. However, this is not the case. Just because LC<sub>A</sub> &lt; LC<sub>B</sub> does not mean that <strong>A &#8211;&gt; B</strong>. Therefore, we can say that we cannot infer a casual ordering of processors just by looking at their timestamps.</p>
<p> </p>
<h2>Atomic Operations</h2>
<p>An atomic operation refers to a set of operations or events that can be combined so that they appear to the rest of the system to be a single operation with only to possible outcomes: <strong>success</strong> or <strong>failure</strong>.</p>
<p> </p>
<p>To read up more on this please visit:</p>
<p><a href="http://en.wikipedia.org/wiki/Atomic_operation">http://en.wikipedia.org/wiki/Atomic_operation</a></p>
<p> </p>
<h2>Critical Section</h2>
<p>In concurrent programming, a critical section is a piece of code that accesses a shared resource that must not be concurrently accessed by more than one thread of execution. <em>[Assuming you read the link above, this can solve the problem between the 2 processes accessing the same memory location].</em></p>
<p>A critical section will usually terminate in a fixed time, and a thread, task or process will only have to wait a fixed time to enter the shared resource.</p>
<p> </p>
<p>By carefully controlling which variables are modified inside and outside the critical section (usually, by accessing important state only from within), concurrent access to that state is prevented. A critical section is typically used when a multithreaded program must update multiple related variables without a separate thread making conflicting changes to that data. In a related situation, a critical section may be used to ensure a shared resource, for example a printer, can only be accessed by one process at a time.</p>
<p> </p>
<p>Want more? Try here: <a href="http://en.wikipedia.org/wiki/Critical_section">http://en.wikipedia.org/wiki/Critical_section</a></p>
<p> </p>
<p>So this leaves on little simple question:</p>
<p><strong><em>Can we safely and atomically update the state on 2 different machines?</em></strong></p>
<p> </p>
<p>The answer? NO! <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p> </p>
<h2>Mutual Exclusion (mutex)</h2>
<p>Mutual exclusion algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections.</p>
<p> </p>
<p>For example, suppose a piece of code is altering a piece of data over several program steps, when another thread starts executing. If this second thread reads from the same piece of data which is currently being overwritten. If the second thread tries to overwrite that data, then the ensuing state will probably be unrecoverable. These shared data being accessed by critical sections of code, must therefore be protected, so that other processes which read from or write to the chunk of data are excluded from running.</p>
<p>A mutex is also a common name for a program object that negotiates mutual exclusion among threads, also called a lock.</p>
<p> </p>
<p> </p>
<p>For more: <a href="http://en.wikipedia.org/wiki/Mutual_exclusion">http://en.wikipedia.org/wiki/Mutual_exclusion</a></p>
<p> </p>
<h3>A Distributed Version of mutex</h3>
<p>A process ‘K’ wants to enter a critical section:</p>
<ul>
<li>It generates a timestamp TS<sub>K</sub></li>
<li>It then sends a request <strong>(K, TS<sub>K</sub>)</strong> to everyone</li>
<li>Waits for a reply from everyone to see if it      is OK to proceed</li>
<li>Process ‘K’ enters its critical section.</li>
</ul>
<p> </p>
<p>When another process – different from ‘K’ – receives a request:</p>
<ul>
<li>If this other process is in its critical      section, it defers its reply</li>
<li>Otherwise, it sends a reply, unless this      process wishes to also try and enter the critical section</li>
<li>If we want to enter the critical section, if      the requestor has a smaller timestamp than us, allow them first, otherwise      defer the reply.</li>
</ul>
<p> </p>
<p>If process ‘K’ does not get a reply from everyone, then it does not enter its critical section.</p>
<p> </p>
<h3>A centralized Version of mutex</h3>
<p>Client:</p>
<ul>
<li>Send a request to the server for a lock on the      mutex</li>
<li>When a reply comes back, start the critical      section</li>
<li>When finished, send a message to the server to      release the mutex.</li>
</ul>
<p> </p>
<p>The Lock Server:</p>
<ul>
<li>If the mutex is available, mark it as being      used by that client, and send a reply. Otherwise, queue the request.</li>
<li>When the mutex is released by the client, if      someone else wants it, pass it to them, otherwise mark it as being      available.</li>
</ul>
<p> </p>
<h2>Two Phase Commit (2PC)</h2>
<h3>PHASE 1</h3>
<p>            A coordinator requests a transaction, and sends a request to all participants.</p>
<p> </p>
<p>For example: <em>C1 sends a request to remove X pounds from an account and C2 sends a request to add X pounds to an account.</em></p>
<p><em> </em></p>
<p>All participants respond as to whether they are willing and able to execute the request, and send either VOTE_COMMIT or VOTE_ABORT. Then each participant logs their vote.</p>
<p> </p>
<h3>PHASE 2</h3>
<p>            The coordinator looks at all the votes, if everyone has voted to commit, then the coordinator send a GLOBAL_COMMIT to everyone, otherwise, it sends a GLOBAL_ABORT.</p>
<p>One receiving the decision from the coordinator, all participants records the decision locally.</p>
<p> </p>
<p>If the decision is ABORT, then all participants ROLL BACK to their previous safe states, otherwise, they continue on, completing the transaction.</p>
<p> </p>
<h2>The Bully Algorithm</h2>
<p>In the example of 2PC described above, how do we decide which node is the coordinator?</p>
<p>For this, we use an algorithm called the <strong>Bully Algorithm</strong>. This relies on some ordering and numbering of the nodes. Once this is done, we can do this:</p>
<p> </p>
<ol>
<li>Node ‘P’ sends an ELECTION to message to all      other nodes with a higher number than itself.</li>
<li>If no one responds, then node ‘P’ wins the      election and becomes the coordinator.</li>
<li>If one of the higher numbered nodes answers,      then this algorithm repeats, but on the higher numbered node.</li>
</ol>
<p> </p>
<p>What if no one responds? Then quite clearly we need a time-out.</p>
<p>view the Bully Algorithm notes on this blog here!: <a href="http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-bully-algorithm/">Bully Algorthim</a></p>
<p> </p>
<h2>Global Clock no more!</h2>
<p>Until the mid 1800’s, all that existed was ‘local time’ based on the suns position. This changed by about 1 minute for every 12 miles. So clearly, a global clock back then was just nonsense.</p>
<p> </p>
<h2>Christian Algorithm</h2>
<ul>
<li>‘P’ requests the time from ‘S’</li>
<li>‘S’ then prepares a response to send the time      ‘T’, and then sends this response at the last possible moment.</li>
<li>‘P’ sets its time to be ‘T + RoundTripTime/2’</li>
</ul>
<p> </p>
<p>Problems with this, is that this algorithm assumes that the RoundTripTime is equal for both sending and receiving, so what if it isn’t?</p>
<p> </p>
<h2><span style="font-weight:normal;"><strong>Berkeley</strong><strong> Algorithm</strong></span></h2>
<ul>
<li>Choose a <strong>master node</strong></li>
</ul>
<p>This master node can then:</p>
<ul>
<li>Request the time from each process.</li>
<li>It then observes the RoundTripTime and      estimates the time in each process and its own time.</li>
<li>Averages the clock times, ignoring any      outlying values.</li>
<li>Sends each process a relative update to their      clock, which can be positive or negative.</li>
</ul>
<p> </p>
<p>A problem here, is what happens to a node that has the master set its clock backwards…</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/479/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=479&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-logical-clocks-and-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>
	</item>
		<item>
		<title>COMP10052 &#8211; Distributed Systems &#8211; Massive Distribution for Performance</title>
		<link>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-massive-distribution-for-performance/</link>
		<comments>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-massive-distribution-for-performance/#comments</comments>
		<pubDate>Wed, 27 May 2009 13:52:37 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Distributed Systems]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=470</guid>
		<description><![CDATA[Definition of a Distributed System
            A distributed System is one in which independent, self-sufficient – often autonomous or heterogeneous – spatially-separated components must use a common interconnect to exchange information and coordinate actions, and allow the whole to appear to the user as one single coherent system.
 
Knowledge is POWER!
Think for a moment, what could you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=470&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Definition of a Distributed System</h2>
<p>            A distributed System is one in which independent, self-sufficient – often autonomous or heterogeneous – spatially-separated components must use a common interconnect to exchange information and coordinate actions, and allow the whole to appear to the user as one single coherent system.</p>
<p> </p>
<h2>Knowledge is POWER!</h2>
<p>Think for a moment, what could you do with a computer? Yeah, your right &#8211; sod all really, specially if its Windows <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  . Now, what about 100 computers? That’s right, now were getting somewhere! Now, let’s look at something better. What about an entire data centre comprising thousands of computers! Well, put simply – holy monkeys that’s a lot of computers, its&#8230; its like being in heaven <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  !</p>
<p> </p>
<h2>Parallel vs. Distributed</h2>
<p>Do you remember the parallelization schemes that a distributed system can be placed into? If not, go here: <a href="http://badgerati.wordpress.com/2009/05/06/distributed-systems-interconnects/">http://badgerati.wordpress.com/2009/05/06/distributed-systems-interconnects/</a> . If it helps, its:</p>
<p> </p>
<ul>
<li>SIMD</li>
<li>MISD</li>
<li>MIMD</li>
</ul>
<p> </p>
<p>Where a distributed system is MIMD-parallel computing when the interconnect is on a network-scale.</p>
<p> </p>
<h2>A Parallelization Example</h2>
<p>Say you were given a list ‘a’, which contained 60 items, along with some integer ‘b’.</p>
<p>Now, you and 2 other people were asked to produce another different list, ‘x’, which is identical to list ‘a’, however, every item has been incremented by 1, and the first occurrence of ‘b+3’ has been removed. How would you do it?</p>
<p> </p>
<p>Let’s say that it is possible to partition the work, so all 3 people can work in parallel. This would finish the job much quicker. This idea is commonly known as the <strong>divide-and-conquer</strong> strategy. And we also can say that a parallelization pattern called <strong>master-and-workers</strong> applies here.</p>
<p> </p>
<h2>Master-and-Worker</h2>
<p>Master-and-worker is when you split the work load evenly between a number of processes that will work in parallel to get the correct answer. Say for example we use the example above. Here we have 3 people and a list of 60 elements. In this case you would split up the work load so each person has a list containing 20 elements from ‘a’:</p>
<p> </p>
<ul>
<li>a<sub>1</sub> = [0:20]</li>
<li>a<sub>2</sub> = [21:40]</li>
<li>a<sub>3</sub> = [41:60]</li>
</ul>
<p> </p>
<p>Here, we will have 3 new lists: x<sub>1</sub>, x<sub>2</sub> and x<sub>3</sub>, where each element has been incremented by 1.</p>
<p>Now what we do it get all 3 new ‘x’ lists, and combine them together to get the one list: ‘x’, which is every element in ‘a’, but incremented by 1.</p>
<p>Now all we need to do it remove the first item in the list that is equal to ‘b+3’.</p>
<p> </p>
<p>This process is called <strong>Split</strong><strong>, Spawn</strong> and <strong>Merge</strong>. First we split the list, then we spawn methods to return a new list ‘x’, then we merge all the new lists together to get the one new list ‘x’.</p>
<p> </p>
<h2>Map-Reduce</h2>
<p>The map-reduce model – would you believe it – comprises of the <strong>map</strong> and <strong>reduce</strong> second-order functions.</p>
<p> </p>
<h3>MAP</h3>
<p>In its simplest form, a map takes a unary function ‘f’ and a collection [c<sub>1</sub>, ···, c<sub>n</sub>], and then returns a collection:</p>
<p> </p>
<ul>
<li>[<em>f</em>(c<sub>1</sub>),      ….., <em>f</em>(c<sub>n</sub>)]</li>
</ul>
<p> </p>
<p>as you can see, the map will apply the required function onto each element of a given collection. Here’s an example:</p>
<p> </p>
<ul>
<li>Say we have      a collection ‘A’<br />
<strong>&gt;&gt;&gt; A = [1, 2, 3, 4, 5]   </p>
<p></strong> </li>
<li>Then we      have a function, say: <strong>incr(x)</strong>, which will return the value ‘x+1’<br />
<strong>&gt;&gt;&gt;def incr(x):<br />
            return x+1</strong></li>
<li>Now we      declare a new collection: ‘B’ = map(incr, A)<br />
<strong>&gt;&gt;&gt;B = map(incr, A)</strong></li>
</ul>
<p> </p>
<ul>
<li>Note how      the first argument is the function <strong>incr</strong>, and the second is the      collection ‘A’.</li>
</ul>
<p> </p>
<ul>
<li>Once this      is done, the map will apply each element of ‘A’ to the function. And when      we print out the new collection ‘B’ we get:<br />
<strong> [2, 3, 4, 5, 6]</strong></li>
</ul>
<p> </p>
<h3>REDUCE</h3>
<p>In its simplest form, reduce takes a binary, associative function, Θ (with an optional, initial value ‘i’) and a collection [c<sub>1</sub>, …, c<sub>n</sub>], and then returns a new value:</p>
<p> </p>
<p>i Θ c<sub>1</sub> Θ … Θ c<sub>n</sub></p>
<p> </p>
<p>So reduce will apply the function to the elements of the given collection. Lets have an example:</p>
<p> </p>
<ul>
<li>Lets use      the collection ‘B’ from the map above:<br />
<strong>&gt;&gt;&gt; B = map(incr, A)   </p>
<p></strong> </li>
<li>Then we      define a binary associative function, that takes to numbers for arguments:<br />
<strong>&gt;&gt;&gt;def prodDup(x,y):<br />
            return (x*2)*(y*2)   </p>
<p></strong> </li>
<li>Now we      apply the function to the collection ‘B’ using reduce:<br />
<strong>&gt;&gt;&gt;reduce(prodDup, B)   </p>
<p></strong> </li>
<li>When      printed, we obtain the value 184,320.</li>
</ul>
<p> </p>
<h2>Map-Reduce Programming Model</h2>
<p>Users implement the following interfaces, which are 2 functions known as the <strong>mapper</strong> and the <strong>reducer</strong>.</p>
<p> </p>
<ul>
<li>Map      (in_key, in_value) -&gt;<br />
            (out_key,      intermediate_value) list</li>
<li>Reduce      (out_key, intermediate_value list) -&gt;<br />
            out_value list</li>
</ul>
<p>This infrastructure takes care of splitting, spawning and merging, as well as fault-tolerance and load balancing.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/470/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=470&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/05/27/comp10052-distributed-systems-massive-distribution-for-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>
	</item>
		<item>
		<title>COMP10052 &#8211; Distributed Systems &#8211; Socket Level Servers</title>
		<link>http://badgerati.wordpress.com/2009/05/26/comp10052-distributed-systems-socket-level-servers/</link>
		<comments>http://badgerati.wordpress.com/2009/05/26/comp10052-distributed-systems-socket-level-servers/#comments</comments>
		<pubDate>Tue, 26 May 2009 21:17:31 +0000</pubDate>
		<dc:creator>Badgerati</dc:creator>
				<category><![CDATA[Distributed Systems]]></category>

		<guid isPermaLink="false">http://badgerati.wordpress.com/?p=459</guid>
		<description><![CDATA[Definition of a Distributed System
            A distributed System is one in which independent, self-sufficient – often autonomous or heterogeneous – spatially-separated components must use a common interconnect to exchange information and coordinate actions, and allow the whole to appear to the user as one single coherent system.
 
Protocols
            In order for separate and independent processes to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=459&subd=badgerati&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Definition of a Distributed System</h2>
<p>            A distributed System is one in which independent, self-sufficient – often autonomous or heterogeneous – spatially-separated components must use a common interconnect to exchange information and coordinate actions, and allow the whole to appear to the user as one single coherent system.</p>
<p> </p>
<h2>Protocols</h2>
<p>            In order for separate and independent processes to make sense of the communication that they are engaging in, then they must follow a set of rules (<strong>protocols</strong>) of engagement and exchange.</p>
<p>            A <strong>protocol</strong> is a set of rules for an <strong>InterProcess Communication </strong>(<strong>IPC</strong>). This protocol stipulates the precise sequence of events that must be enacted by the communicating processes for them to engage in communication and exchange information.</p>
<p>            Some communication events are <strong>unicast</strong>, that is, from one single process to another single process. So a form of one-to-one communication. And then, some events are <strong>multicast</strong> – from one single process to many other processes, so a form of one-to-many communication.</p>
<p> </p>
<h2>API Calling</h2>
<p>            A protocol uses the API calls from IPC that were discussed in the <strong>Syncing and Blocking SEND and RECEIVE Processes</strong> page. These API calls were:</p>
<p> </p>
<ul>
<li><strong>SEND</strong> (receiver      process) (data to be sent)</li>
<li><strong>RECEIVE</strong> – the      argument for this operation is the location of where the data is to be      placed, and possibly the sender process.</li>
</ul>
<ul>
<li><strong>ACCEPT </strong> &#8211;       a receiver process calls this to specify its readiness to engage in      communication</li>
<li><strong>CONNECT</strong>  &#8211;       the sender process calls this to initiate the engagement</li>
<li><strong>DISCONNECT</strong> &#8212; either      process must use this operation to clearly disengage from communication.</li>
</ul>
<p> </p>
<p>In this case, the <strong>Web Server</strong> is the <strong>SENDer</strong> and the <strong>Web Browser</strong> is the <strong>RECIEVEr</strong>.</p>
<p> </p>
<h2>Synchronization</h2>
<p>            REMEMBER, THERE IS <strong>NO</strong> GLOBAL CLOCK.</p>
<p>            Say for example, we have a timestamp <strong><em>t</em></strong> for the Web Server. In reality, this time will be later in real time, than the timestamp <strong><em>t</em>’ </strong>for the Web Browser, even though it is obvious that <strong><em>t</em>’ &lt; <em>t</em></strong>.</p>
<p>            If this is so, then the Web Browsers <strong>SEND</strong>, will have no <strong>RECEIVE</strong> counterpart in the Web Server. Because of this, data may not be exchanged between the Web Server and Web Browser.</p>
<p> </p>
<p>            There is one way however, to try and avoid this problem. That is:</p>
<p> </p>
<ul>
<li>The Web      Browser sends a <strong>Synchronous SEND</strong>. Ie, from the page mentioned      above, a <strong>SEND</strong> that waits for acknowledgement that the required data      has been placed into the buffer of the receiver process.</li>
<li>The Web      Server keeps on looping around <strong>RECEIVE</strong>, until a <strong>SEND</strong> has      been caught from the Web Browser. Remember, a <strong>RECEIVE</strong> is <em>always</em> <strong>Synchronous</strong>.</li>
</ul>
<p> </p>
<h2>Sockets</h2>
<p>Sockets are a programming abstraction which is used to implement low-level IPC. For example, 2 processes exchange information by each process having a socket of its own. They can then read/write from/onto their sockets.</p>
<p>Sockets are created, and if in a client-server approach, then these sockets are prepared for sending and receiving messages. With this, we can see that sending data is just done by writing to ones socket, and receiving data is done by reading from the socket.</p>
<p> </p>
<h2>Client-Side Sockets</h2>
<p>A Client-side socket is best understood as the endpoint of a conversation. For example, they are short-lived. In a web browser, a socket is created to send a request, receive the response, and then once that is done, the socket is destroyed (discarded).</p>
<p>In order to set up a client-side, we do as follows:</p>
<p> </p>
<ul>
<li>Create a      socket for a given transport (TCP) and IP (IPv4).</li>
<li>Connect to      a server on the port corresponding to the desired protocol. (80 for HTTP).</li>
<li>When the      connect returns without error, then the client-side set-up is complete <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p> </p>
<p>Once the socket is up, the message-exchange stage can take place:</p>
<p> </p>
<ul>
<li>The client      sends a request for a specific HTML page, (lets say <a href="http://badgerati.wordpress.com/">http://badgerati.wordpress.com</a> ) <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  through its socket.</li>
<li>Then,      through the same socket, it waits for a response to come, and then      processes it.</li>
</ul>
<p> </p>
<p>Once this is done, the socket is then discarded.</p>
<p> </p>
<h2>Server-Side Sockets</h2>
<p>A server socket behaves more like a dispatcher. This is because they do not normally send or receive any data: typically, they simply listen for connections on the host and port that the socket server is bound to.</p>
<p>When a server socket gets one connection, it also gets a new socket in response to that event. It will then spawn a handler process, or thread, which is the one that actually uses the new socket to exchange messages with the client-connected socket.</p>
<p>After this, the server socket then simply goes back to listen for more connections.</p>
<p> </p>
<p>To set up a server socket, we follow these steps:</p>
<p> </p>
<ul>
<li>Create the      server socket for a given transport (TCP) and IP (IPv4).</li>
<li>Set the      server socket options, such as, it this socket reusable?</li>
<li>Bind the      server socket to a host address (localhost) and a port (80).</li>
<li>Start      listening to connections on the server socket and set the maximum number      that could be left waiting.</li>
</ul>
<p> </p>
<p>The connection handling stage is a loop, which:</p>
<p> </p>
<ul>
<li>The server      socket first blocks waiting connections to accept connections.</li>
<li>When a      connection is accepted, 2 pieces of information result: the new      client-connected socket has been created and the host and the port of      connecting client.</li>
<li>The server      process then handles the connection, for example it could spawn a      dispatcher passing it the socket to be used and start it.</li>
<li>The server      process can then continue the loop.</li>
<li>(the      client-connected socket must be ordered to shutdown and close when the      handler is done and returns to the parent).</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/badgerati.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/badgerati.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/badgerati.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/badgerati.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/badgerati.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/badgerati.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/badgerati.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/badgerati.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/badgerati.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/badgerati.wordpress.com/459/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=badgerati.wordpress.com&blog=7242445&post=459&subd=badgerati&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://badgerati.wordpress.com/2009/05/26/comp10052-distributed-systems-socket-level-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4afba4cfcf683e791b8ff40d8088df9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Badgerati</media:title>
		</media:content>
	</item>
	</channel>
</rss>