1998Q3/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: lockless system &#45; foolproof? -->
<!--X-From-R13: Xnzrf Ivyfba <wjvyfbaNebpurfgre.ee.pbz> -->
<!--X-Date: Sun, 30 Aug 1998 12:44:54 &#45;0700 -->
<!--X-Message-Id: 98083015354306.12025@d185d1e96 -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199808301603.KAA01123@ami&#45;cg.GraySage.Edmonton.AB.CA -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: lockless system - foolproof?</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:jwilson#rochester,rr.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="msg00876.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00878.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00875.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00879.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00877">Author</A>
&nbsp;|&nbsp;<A HREF="#00877">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00877">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: lockless system - foolproof?</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: lockless system - foolproof?</LI>
<LI><em>From</em>: James Wilson &lt;<A HREF="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</A>&gt;</LI>
<LI><em>Date</em>: Sun, 30 Aug 1998 14:31:14 -0400</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
On Sun, 30 Aug 1998, Chris Gray wrote:
&gt;[James Wilson:]
&gt;
&gt; &gt;Assuming this solution (please let me know if there are any other solutions),
&gt; &gt;the possibility arises of having to collect a large number of such database
&gt; &gt;commits due to some operation on a complex compound object, where guaranteeing
&gt; &gt;the atomicity of access to subobjects is not sufficient. Then a thread which
&gt; &gt;tries to grab all the objects in question, operate upon them in such a way that
&gt; &gt;the overall constraints are satisfied, and save the changes, would be
&gt; &gt;vulnerable to frequent, possibly endless restarts as one or another of the many
&gt; &gt;objects it is trying to keep coherent is changed.

&gt;I certainly don't want to speak for JC, but here's my understanding...

[snip]

&gt;There could be lots of retries needed on busy objects. I believe some of the
&gt;suggested solutions involved the scheduling of events, with the final
&gt;attempt that of running the contentious (hah!) event all by itself,
&gt;with nothing else running.

yes, contentious is a good word for it. the last clause would of course result
in complete system-wide stoppage while the contentious event is processed. 
This is much stronger than is actually needed; all that is required for
correctness is that events which would collide are not run concurrently. 

Suppose that I have constrained my user scripts so they can only access
some finite set of persistent objects within a given event, and that set can
be determined before the event is actually invoked . For instance, if an
event requires access to at most ten persistent objects, those ten
can be locked before the event is invoked. One could also distinguish 
between read-only and read-write access to allow shared access 
where appropriate.

Leaving aside for a moment the question of whether or not such a set
can be determined automatically (or what mud language structures would 
be required to support that sort of analysis), would it help? 

In the case of the nodes A and B which mutually reference one another, the
event which breaks the cycle would be flagged as needing two objects, A
and B, and would lock both of them. If other events are already manipulating
A or B, the event will be stalled until they're done. Similarly, events that
need to access A or B stall until the cycle-breaker is done. 

If events can nest (i.e. event 1 starts event 2 and does not complete until
event 2 completes) then this system would be subject to deadlock, as 
event E could lock A, event F could lock B,  and each could then nest by
invoking one another. So the above is incompatible with nested events. 
One would be forced to make all events asynchronous, so event E's 
spawning of  event F would not result in the execution of F *within* E, but
rather the execution of F sometime after its spawning. This is a significant 
restriction.

Another problem has to do with obtaining the set of objects a given event
wants to operate upon. If these are fixed (event E always operates on object A)
there is no problem, but presumably one would like to allocate new objects
at runtime and invoke events which manipulate them. In this case, there 
could be some computation done before an event is invoked which determines
the 'working set'. Consider the case where an event is to manipulate a linked
list, where each node in the list must be locked while the event is in
progress. There must be a point at which the linked list is traversed and the
objects in question locked; thus, one must protect THIS segment from deadlock
as well! Otherwise two threads could start at different ends of the list and
try to lock each node in it; they could each get halfway and freeze, waiting
for the other to relinquish the locks on the half they don't have... Mutexing
the procedure which obtains the locks could be a solution, so only one thread
is locking objects at any given time, but this could be a serious bottleneck
(as waiting for a previously locked object would block the invocation of new
events).

Alternatively, the set of objects accessible to the event could be passed when
the event is pushed on the event stack. Thus if event E has access to object A
which points to objects B and C, E can push a new event F which will manipulate 
B and C simultaneously. Manipulating an entire list could be accomplished by
an event E obtaining access to A, spawning F which has access to A and B, 
spawning G which has access to A, B, and C, etc... unwieldy indeed. 

James


</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00875" HREF="msg00875.html">[MUD-Dev] Re: lockless system - foolproof?</A></STRONG>
<UL><LI><EM>From:</EM> Chris Gray &lt;cg#ami-cg,GraySage.Edmonton.AB.CA&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00876.html">[MUD-Dev] Re: Modular MUD [Was:Finer points of Telnet programming ...]</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00878.html">[MUD-Dev] Re: lockless system - foolproof?</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00875.html">[MUD-Dev] Re: lockless system - foolproof?</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00879.html">[MUD-Dev] Re: lockless system - foolproof?</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00877"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00877"><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: Intermud Communication...is it worth it?</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00932" HREF="msg00932.html">[MUD-Dev] Re: Intermud Communication...is it worth it?</A></strong>, 
Ling <a href="mailto:K.L.Lo-94#student,lboro.ac.uk">K.L.Lo-94#student,lboro.ac.uk</a>, Thu 03 Sep 1998, 17:47 GMT
</LI>
</ul>
</ul>
</LI>
<LI><strong><A NAME="00914" HREF="msg00914.html">[MUD-Dev] VT-100 and other terminal data</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Wed 02 Sep 1998, 19:14 GMT
<LI><strong><A NAME="00881" HREF="msg00881.html">[MUD-Dev] Admin: OS wars and avocacy are off-topic</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sun 30 Aug 1998, 21:26 GMT
<LI><strong><A NAME="00875" HREF="msg00875.html">[MUD-Dev] Re: lockless system - foolproof?</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 30 Aug 1998, 16:06 GMT
<UL>
<LI><strong><A NAME="00877" HREF="msg00877.html">[MUD-Dev] Re: lockless system - foolproof?</A></strong>, 
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 30 Aug 1998, 19:44 GMT
</LI>
<LI><strong><A NAME="00879" HREF="msg00879.html">[MUD-Dev] Re: lockless system - foolproof?</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sun 30 Aug 1998, 20:23 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00874" HREF="msg00874.html">[MUD-Dev] Re: Modular MUD</A></strong>, 
D. B. Brown <a href="mailto:dbrown1#stny,lrun.com">dbrown1#stny,lrun.com</a>, Sun 30 Aug 1998, 16:04 GMT
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00880" HREF="msg00880.html">[MUD-Dev] Re: Modular MUD</A></strong>, 
quzah <a href="mailto:quzah#geocities,com">quzah#geocities,com</a>, Sun 30 Aug 1998, 21:10 GMT
<UL>
<LI><strong><A NAME="00884" HREF="msg00884.html">[MUD-Dev] Re: Modular MUD</A></strong>, 
Caliban Tiresias Darklock <a href="mailto:caliban#darklock,com">caliban#darklock,com</a>, Mon 31 Aug 1998, 12:04 GMT
</LI>
</UL>
</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>