1998Q2/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: atomic functions -->
<!--X-From-R13: "Tryvk O. Qebrf" <sryvkNkf1.fvzcyrk.ay> -->
<!--X-Date: Sat, 2 May 1998 16:25:52 &#45;0700 -->
<!--X-Message-Id: 199805022323.BAA14725#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="msg00332.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00334.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00420.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00334.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00333">Author</A>
&nbsp;|&nbsp;<A HREF="#00333">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00333">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>: Sun, 3 May 1998 01:23:12 +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 Fri, May 01, 1998 at 03:11:58PM +0200, Felix A. Croes wrote:
&gt;[...]
&gt; &gt; To transplant the idea of atomic functions to your model, in which
&gt; &gt; functions are already implicitly atomic, make the following change:
&gt; &gt; rather than
&gt; &gt; 
&gt; &gt; 	atomic foo()
&gt; &gt; 	{
&gt; &gt; 	    /* code of foo */
&gt; &gt; 	}
&gt; &gt; 
&gt; &gt; use
&gt; &gt; 
&gt; &gt; 	foo()
&gt; &gt; 	{
&gt; &gt; 	    /* code fragment 1 */
&gt; &gt; 
&gt; &gt; 	    atomic {
&gt; &gt; 		/* code fragment 2, executed atomically */
&gt; &gt; 	    }
&gt; &gt; 
&gt; &gt; 	    /* code fragment 3 */
&gt; &gt; 	}
&gt;
&gt; So atomic fragments are akin to critical sections?

They are similar, though critical sections are handled differently in
my server.  They are run with "infinite" resources -- that is, the event
will not run out of ticks or stack frames while in the critical section.
Obviously, the use of critical sections cannot be allowed to guest-
programmers on a mud, which is one of my reasons for considering to
add relatively harmless atomic functions/fragments.


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

At present, my server does not have atomic functions/fragments/sections
(I rather like "sections"!) at all.  I mean to add multi-threading
similar to yours: events work on a local copy of data and upon
completion either commit the changes or fail, depending on whether
other events already committed changes to the same data meanwhile.
However, function calls occur within the current event and do not
start a new one, and runtime errors do not cause the current event to
fail.

My reasons for considering to add atomic sections as a feature are:

 1) I find them desirable.
 2) after going multi-threaded as outlined above, they will be trivial
    to implement.


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

Critical code exists, and a programmer may decide to protect it.
To the programmer who makes that decision, atomic sections will be
a lot easier to use and comprehend than the various checks that
would have to be made to ensure that the code will be executed
either as a whole or not at all.  Implementing atomic sections as
atomic functions is done to make this easy (no new code structure
to learn).

Being able to nest atomic sections is important to me.

The performance hit does not bother me.  On a mud with programming
guests, there is no real protection against someone executing an
infinite loop.  Rather, ensure that costly code is actually made
costly to use: double the amount of ticks spent while executing
atomic sections, and implement per-programmer tick quotas.

Can your solution of letting runtime errors cancel the current
event deal with the following case:

	foo()
	{
	    A();
	    if B() succeeds then
		C();
	    else
		D();
	}

with the requirement that A() and C() together, or A() and D()
together must be executed atomically?


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

The event fails to obtain this result.  It may either catch the error
and perform some alternative action, or complete (and eventually commit)
with an error.  I do not consider this to be a problem.  Rather, I
think that events which do not disappear when an error occurs facilitate
debugging. :)


&gt;[...]
&gt; One different thing about the system I'm describing is that
&gt; events using an intersecting working set don't know that they will fail and
&gt; be rescheduled until they all try and C&amp;C.  This is where atomic fragments
&gt; could be beneficial since the working set modifications could take place
&gt; inside them, waiting on other events as required.  My approach:  if an
&gt; event succeeds C&amp;C, other events with intersecting working sets are
&gt; notified and immediately rescheduled, rather than waiting until they are
&gt; try (and assuredly fail) C&amp;C.  (This has been on the list before, too).
&gt;
&gt; This way, I'm not redoing operations I've already performed and thrown out
&gt; to the extent I would if the entire event went through its processing
&gt; before finding out it couldn't commit changes.

I am not yet sure whether I want to do this, since finding out which
other still-running events have an intersecting working set may be a
costly operation, and locking would be needed to store the information
in a common spot.

Felix Croes

-- 
MUD-Dev: Advancing an unrealised future.

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00332.html">[MUD-Dev] Re: PK and my "Mobless MUD" idea</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00334.html">[MUD-Dev] Re: atomic functions</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00420.html">[MUD-Dev] Re: atomic functions</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00334.html">[MUD-Dev] Re: atomic functions</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00333"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00333"><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><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>
<LI><strong><A NAME="00335" HREF="msg00335.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
<UL>
<LI><strong><A NAME="00336" HREF="msg00336.html">[MUD-Dev] Re: atomic functions</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Sun 03 May 1998, 05:49 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00338" HREF="msg00338.html">[MUD-Dev] Re: atomic functions</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 03 May 1998, 17:16 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>