1998Q2/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: atomic functions -->
<!--X-From-R13: Eunja Vnycraal <znynpunvNvanzr.pbz> -->
<!--X-Date: Fri, 1 May 1998 10:27:42 &#45;0700 -->
<!--X-Message-Id: 19980501132632.B1139#sun104,humb.nt.com -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199805011311.PAA02993#xs1,simplex.nl -->
<!--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:malachai#iname,com">
</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="msg00297.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00299.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00296.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00331.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00298">Author</A>
&nbsp;|&nbsp;<A HREF="#00298">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00298">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>: Shawn Halpenny &lt;<A HREF="mailto:malachai#iname,com">malachai#iname,com</A>&gt;</LI>
<LI><em>Date</em>: Fri, 1 May 1998 13:26:32 -0400</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>
On Fri, May 01, 1998 at 03:11:58PM +0200, Felix A. Croes wrote:
&gt; Shawn Halpenny &lt;malachai#iname,com&gt; wrote:
&gt; 
&gt; &gt; On Thu, Apr 30, 1998 at 03:59:20AM +0200, Felix A. Croes wrote:
&gt; &gt;[...]
&gt; &gt; &gt;     An atomic function is a function that succeeds or fails as a
&gt; &gt; &gt;     whole.  Any runtime error that is not caught within the function
&gt; &gt; &gt;     will lead to the entire function call, with all its effects
&gt; &gt; &gt;     and side-effects, being undone.
&gt; &gt;
&gt; &gt; For me, a function cannot be executed without having a corresponding
&gt; &gt; event:  it is tied tightly to the lockless-ness of the DB commits. 
&gt; &gt; Events accumulate a working set.  If those objects are committed (and
&gt; &gt; they will be if no other event has already finished with its objects
&gt; &gt; and has C&amp;C'd), then the thread that was executing that event
&gt; &gt; effectively "dies" (although it's kept around in a pool for subsequent
&gt; &gt; quick reuse) and the event is no more.
&gt; 
&gt; If I understand you correctly, you use "event" to denote the unit of
&gt; execution as viewed from within the mud, and "thread" for how the
&gt; underlying implementation manages events.  I have been using "thread"
&gt; to mean both, assuming a 1-to-1 mapping, or rather giving the matter
&gt; no thought at all.  To simplify matters, I will adopt your terminology.

Yep.  One event per thread is what it boils down to, so I use event and
thread pretty much interchangeably as well.

&gt; To transplant the idea of atomic functions to your model, in which
&gt; functions are already implicitly atomic, make the following change:
&gt; rather than
&gt; 
&gt; 	atomic foo()
&gt; 	{
&gt; 	    /* code of foo */
&gt; 	}
&gt; 
&gt; use
&gt; 
&gt; 	foo()
&gt; 	{
&gt; 	    /* code fragment 1 */
&gt; 
&gt; 	    atomic {
&gt; 		/* code fragment 2, executed atomically */
&gt; 	    }
&gt; 
&gt; 	    /* code fragment 3 */
&gt; 	}

So atomic fragments are akin to critical sections?  For me, methods can
execute in their own context (essentially the call stack of an event's
processing is an entire critical section).  Since they receive current
copies of any data they touch, rather than having to wait for it to
become available, though, there's no waiting upon entry.  Given the way
I've structured things, atomic fragments don't add much benefit (but see
below).

If you are moving toward a lockless DB scheme, will you still require
atomic fragments?  If you have a 1-to-1 mapping between thread and event,
do the atomic sections only come into play when multiple events are
executing the same method?  Currently, I've got each method executing in
its own stack with local copies of all data.

Explicitly defining an atomic function would require more programmer
work.  In a free user programming environment, I don't want to require
people to decide whether the function they just wrote to make their
sword talk needs to be atomic or have atomic sections within it.  For
now, I'm opting to leave it up to the server to decide the atomicity of
things (which it does by way of the event and DB models).  An
experienced programmer can probably outdo the server if given the
capability to declare atomic blocks, but a newbie would be more
inclined to either not declare them at all (in which case, I'd have to
rely on a system like I've already got in mind) or declare them poorly
and result in performance worse than the server would obtain doing it
itself.  

&gt; &gt; I would consider each executing
&gt; &gt; event method an atomic function as you've described them--all of the
&gt; &gt; effects undone on failed C&amp;C reset the world state for that event to
&gt; &gt; the new current state.  A runtime error in a function essentially
&gt; &gt; amounts to a failed C&amp;C, since the end result is the same:  no changes
&gt; &gt; persist.  However, a failed function will cause the event method in
&gt; &gt; which it was called to not be rescheduled and thus it will not attempt
&gt; &gt; to C&amp;C again.  A C&amp;C failure without a corresponding function error is
&gt; &gt; perfectly acceptable and, in fact, required.  
&gt; 
&gt; In this model, atomic code fragments would still be useless, since
&gt; an error in an atomic fragment would cancel the entire event.  To
&gt; make them meaningful, you would need a way to (optionally) catch
&gt; errors in an event.  That way, individual bits of atomic code could
&gt; fail without the entire event failing.

What happens if there is an error in an atomic fragment, and the rest of
the event requires a result out of that fragment?

[ execution order of atomic fragments ]

&gt; What it actually does is impose an execution order on bits of
&gt; atomically executed code:
&gt; 
&gt; 	foo()
&gt; 	{
&gt; 	    atomic {
&gt; 		/* code fragment 1 */
&gt; 	    }
&gt; 	    atomic {
&gt; 		/* code fragment 2 */
&gt; 	    }
&gt; 	    atomic {
&gt; 		/* code fragment 3 */
&gt; 	    }
&gt; 	}

I see now.  This does not occur between events, but only within the
function itself.

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

You have much finer granularity than I have.

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

One different thing about the system I'm describing is that
events using an intersecting working set don't know that they will fail and
be rescheduled until they all try and C&amp;C.  This is where atomic fragments
could be beneficial since the working set modifications could take place
inside them, waiting on other events as required.  My approach:  if an
event succeeds C&amp;C, other events with intersecting working sets are
notified and immediately rescheduled, rather than waiting until they are
try (and assuredly fail) C&amp;C.  (This has been on the list before, too).

This way, I'm not redoing operations I've already performed and thrown out
to the extent I would if the entire event went through its processing
before finding out it couldn't commit changes.

-- 
Shawn Halpenny

I know that you believe you understand what you think I said, but,
I am not sure you realize that what you heard is not what I meant.  

-- 
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="00331" HREF="msg00331.html">[MUD-Dev] Re: atomic functions</A></strong>
<ul compact><li><em>From:</em> "Jon A. Lambert" &lt;jlsysinc#ix,netcom.com&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00296" HREF="msg00296.html">[MUD-Dev] Re: atomic functions</A></STRONG>
<UL><LI><EM>From:</EM> "Felix A. Croes" &lt;felix#xs1,simplex.nl&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00297.html">[MUD-Dev] Monthly FAQ Posting</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00299.html">[MUD-Dev] Re: PK and my "Mobless MUD" idea</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00296.html">[MUD-Dev] Re: atomic functions</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00331.html">[MUD-Dev] Re: atomic functions</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00298"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00298"><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>
<ul compact>
<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>
</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>
<LI><strong><A NAME="00334" HREF="msg00334.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:26 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>