1998Q2/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: atomic functions -->
<!--X-From-R13: "Tryvk O. Qebrf" <sryvkNkf1.fvzcyrk.ay> -->
<!--X-Date: Fri, 1 May 1998 06:13:26 &#45;0700 -->
<!--X-Message-Id: 199805011311.PAA02993#xs1,simplex.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: atomic functions</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:felix#xs1,simplex.nl">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00295.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00297.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00297.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00298.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00296">Author</A>
&nbsp;|&nbsp;<A HREF="#00296">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00296">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: atomic functions</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] Re: atomic functions</LI>
<LI><em>From</em>: "Felix A. Croes" &lt;<A HREF="mailto:felix#xs1,simplex.nl">felix#xs1,simplex.nl</A>&gt;</LI>
<LI><em>Date</em>: Fri, 1 May 1998 15:11:58 +0200 (MET DST)</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Sender</em>: "Petidomo List Agent -- Kanga.Nu version" &lt;<A HREF="mailto:petidomo#kanga,nu">petidomo#kanga,nu</A>&gt;</LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
Shawn Halpenny &lt;malachai#iname,com&gt; wrote:

&gt; On Thu, Apr 30, 1998 at 03:59:20AM +0200, Felix A. Croes wrote:
&gt;[...]
&gt; &gt;     An atomic function is a function that succeeds or fails as a
&gt; &gt;     whole.  Any runtime error that is not caught within the function
&gt; &gt;     will lead to the entire function call, with all its effects
&gt; &gt;     and side-effects, being undone.
&gt;
&gt; For me, a function cannot be executed without having a corresponding
&gt; event:  it is tied tightly to the lockless-ness of the DB commits. 
&gt; Events accumulate a working set.  If those objects are committed (and
&gt; they will be if no other event has already finished with its objects
&gt; and has C&amp;C'd), then the thread that was executing that event
&gt; effectively "dies" (although it's kept around in a pool for subsequent
&gt; quick reuse) and the event is no more.

If I understand you correctly, you use "event" to denote the unit of
execution as viewed from within the mud, and "thread" for how the
underlying implementation manages events.  I have been using "thread"
to mean both, assuming a 1-to-1 mapping, or rather giving the matter
no thought at all.  To simplify matters, I will adopt your terminology.

To transplant the idea of atomic functions to your model, in which
functions are already implicitly atomic, make the following change:
rather than

	atomic foo()
	{
	    /* code of foo */
	}

use

	foo()
	{
	    /* code fragment 1 */

	    atomic {
		/* code fragment 2, executed atomically */
	    }

	    /* code fragment 3 */
	}


&gt; I would consider each executing
&gt; event method an atomic function as you've described them--all of the
&gt; effects undone on failed C&amp;C reset the world state for that event to
&gt; the new current state.  A runtime error in a function essentially
&gt; amounts to a failed C&amp;C, since the end result is the same:  no changes
&gt; persist.  However, a failed function will cause the event method in
&gt; which it was called to not be rescheduled and thus it will not attempt
&gt; to C&amp;C again.  A C&amp;C failure without a corresponding function error is
&gt; perfectly acceptable and, in fact, required.  

In this model, atomic code fragments would still be useless, since
an error in an atomic fragment would cancel the entire event.  To
make them meaningful, you would need a way to (optionally) catch
errors in an event.  That way, individual bits of atomic code could
fail without the entire event failing.


&gt; &gt; Atomic functions would be used to enforce consistency -- just like a
&gt; &gt; thread either fails or succeeds without leaving the mud in an
&gt; &gt; inconsistent, half-completed state.  Of course, every function called
&gt; &gt; at the beginning of a thread is effectively called atomically, so
&gt; &gt; code that depends on atomic functions can be replaced by code that
&gt; &gt; depends on (atomic) threads.  The advantage of atomic functions
&gt; &gt; would be to place the function call within the wider thread
&gt; &gt; context, which would be similar to imposing an execution order on
&gt; &gt; threads.  Also, calls to atomic functions could be nested.
&gt;
&gt; I'm not sure I understand how this alone will impose an execution
&gt; order.  If I have threads (I could even substitute "events") executing
&gt; in parallel, normally whichever is able to C&amp;C first, wins.  Any order
&gt; I impose on executing events depends on sequence numbers associated
&gt; with the events themselves.  Design details about the sequencing are still
&gt; muddy, since I'm re-examining my approach.

What it actually does is impose an execution order on bits of
atomically executed code:

	foo()
	{
	    atomic {
		/* code fragment 1 */
	    }
	    atomic {
		/* code fragment 2 */
	    }
	    atomic {
		/* code fragment 3 */
	    }
	}

Now, focusing on atomic code and abstracting from the rest, you can
map the sequence of code fragments to a sequence of atomic events.

Having events execute in parallel and compete for completion is done
to get the mud to run efficiently on multi-processor architectures.
But the atomic code property is also desirable from a software design
point of view, which is why I am trying to separate atomicity and
events.  It gets especially interesting when you nest atomic code,
allowing you to make code atomic on several abstraction levels.

Felix Croes

-- 
MUD-Dev: Advancing an unrealised future.

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00420" HREF="msg00420.html">[MUD-Dev] Re: atomic functions</A></strong>
<ul compact><li><em>From:</em> J C Lawrence &lt;claw#under,engr.sgi.com&gt;</li></ul>
<li><strong><A NAME="00298" HREF="msg00298.html">[MUD-Dev] Re: atomic functions</A></strong>
<ul compact><li><em>From:</em> Shawn Halpenny &lt;malachai#iname,com&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00295.html">[MUD-Dev] Re: (fwd) AD: [custom graphical] whitestar</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00297.html">[MUD-Dev] Monthly FAQ Posting</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00297.html">[MUD-Dev] Monthly FAQ Posting</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00298.html">[MUD-Dev] Re: atomic functions</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00296"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00296"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Re: (fwd) Re: POLL: Games ruined by bad players (Player killers, tank rushers etc)</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00397" HREF="msg00397.html">[MUD-Dev] Re: (fwd) Re: POLL: Games ruined by bad players (Player killers, tank rushers etc)</A></strong>, 
Dr. Cat <a href="mailto:cat#bga,com">cat#bga,com</a>, Tue 05 May 1998, 14:00 GMT
<UL>
<LI><strong><A NAME="00400" HREF="msg00400.html">[MUD-Dev] Re: (fwd) Re: POLL: Games ruined by bad players (Player killers, tank rushers etc)</A></strong>, 
Adam Wiggins <a href="mailto:adam#angel,com">adam#angel,com</a>, Tue 05 May 1998, 15:21 GMT
</LI>
</UL>
</LI>
</ul>
<LI><strong><A NAME="00416" HREF="msg00416.html">[MUD-Dev] Re: (fwd) Re: POLL: Games ruined by bad players (Player killers, tank rushers etc)</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Wed 06 May 1998, 05:33 GMT
</LI>
</ul>
</LI>
<LI><strong><A NAME="00297" HREF="msg00297.html">[MUD-Dev] Monthly FAQ Posting</A></strong>, 
Ling <a href="mailto:K.L.Lo-94#student,lboro.ac.uk">K.L.Lo-94#student,lboro.ac.uk</a>, Fri 01 May 1998, 17:11 GMT
<LI><strong><A NAME="00296" HREF="msg00296.html">[MUD-Dev] Re: atomic functions</A></strong>, 
Felix A. Croes <a href="mailto:felix#xs1,simplex.nl">felix#xs1,simplex.nl</a>, Fri 01 May 1998, 13:13 GMT
<UL>
<LI><strong><A NAME="00298" HREF="msg00298.html">[MUD-Dev] Re: atomic functions</A></strong>, 
Shawn Halpenny <a href="mailto:malachai#iname,com">malachai#iname,com</a>, Fri 01 May 1998, 17:27 GMT
<UL>
<LI><strong><A NAME="00331" HREF="msg00331.html">[MUD-Dev] Re: atomic functions</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Sat 02 May 1998, 18:16 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00420" HREF="msg00420.html">[MUD-Dev] Re: atomic functions</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Wed 06 May 1998, 17:39 GMT
</LI>
</UL>
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00333" HREF="msg00333.html">[MUD-Dev] Re: atomic functions</A></strong>, 
Felix A. Croes <a href="mailto:felix#xs1,simplex.nl">felix#xs1,simplex.nl</a>, Sat 02 May 1998, 23:25 GMT
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>