1998Q4/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: DevMUD:  Inheritable modules -->
<!--X-From-R13: Xnzrf Ivyfba <wjvyfbaNebpurfgre.ee.pbz> -->
<!--X-Date: Sun, 22 Nov 1998 15:04:20 &#45;0800 -->
<!--X-Message-Id: 98103108092400.26004@d185d1e96 -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199810310743.BAA11335@dfw&#45;ix10.ix.netcom.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: DevMUD:  Inheritable modules</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="msg00850.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00852.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00704.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00617.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00851">Author</A>
&nbsp;|&nbsp;<A HREF="#00851">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00851">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: DevMUD:  Inheritable modules</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: DevMUD:  Inheritable modules</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>: Sat, 31 Oct 1998 07:53:01 -0500</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 Wed, 31 Dec 1969, Jon A. Lambert wrote:

&gt;Why couldn't each module implement it's own desired level of 
&gt;threading.  The loader would dynamically load the module and then 
&gt;start it running using a createthread(), startthread() mechanism.  
&gt;Each module then starts as a single thread. The module writer need 

threads don't make sense for every module. Suppose I come up with
a fast_graphics module which simply exports a lot of functions? Moreover there
are other modules that will need many threads. I would prefer we take this on a
case-by-case basis; loading of the module should invoke some _init or DLLMain
function (this is how dlopen and Win32's LoadLibrary work), which, if the
module writer deems proper, can launch threads.

&gt;not even be concerned that they are threaded. Since there seems to be 
&gt;agreement that a common module interface is necessary, why not make 
&gt;that small bit of common inter-module interface code thread-safe by 
&gt;issuing the necessary locking mechanisms within the interface wrapper 
&gt;itself.  

this is not so straightforward. Avoiding deadlocks is a difficult science. 

&gt;ModuleA calls ModuleB wrapper ----&gt; ModuleB function
&gt;ModuleB calls ModuleA wrapper ----&gt; ModuleA function
&gt;
&gt;All the code in the wrapper is fully reusable, generic and 
&gt;threadsafe.  It just contains bindings (data) for the module 
&gt;it is attached to.  Creation of wrappers could even be 
&gt;automated.  It might also be useful to require the loaded
&gt;module to use a standard function name (i.e. init()) so
&gt;we can have a handle to start a thread on.  And perhaps
&gt;a kill() or stop() handle.

if there is a mutex on each of Module A's functions such that only one thread
may be in a function at once, there will be a TON of needless locking (you
don't need to lock atoi(), but you do need to lock strtok()). Moreover you will
have deadlocks galore, as functions try to call one another but have to block
on a mutex.

&gt;The base loader could:
&gt;
&gt;dynamic_load()
&gt;process_symbols()
&gt;build_wrapper()
&gt;create_thread()
&gt;start_thread()
&gt;
&gt;A module wrapper's data portion might contain a simple message 
&gt;queue and handled as such.  Thus a module could call 
&gt;the wrapper function receive_message() which pops() the wrapper
&gt;queue and causes one of the modules routines to be executed.
&gt;The return of the function would of course occur in the wrapper
&gt;and any return value is sent_back to the caller via a wrapper
&gt;function send_message().  Note that the owning threads during
&gt;function calls will be the called module's.  So single-threaded
&gt;modules can interface easily with multi-threaded modules.

I have a number of problems with this.

	a. the module abstraction is not necessarily isomorphic to an
independent thread receiving and emitting asynchronous messages. In 
particular, a module may not NEED to serialize access to everything inside it -
some functions may be totally reentrant, some data structures would be better
served by monitors, some functions may be independent of one another and not
need to be serialized.
   	b. message-passing raises a whole host of programming issues. Nicholas
suggested this at one point, and I won't reiterate my position, except to say
that message-passing will NOT be simple and understandable to module writers.
int what = foo () makes sense to 100% of or target audience. the cruft needed
to send a message, then wait for THE RIGHT MESSAGE to return (as opposed to
messages from other modules that you didn't know were about to send you
messages) is hard.
	c. it's hard to avoid deadlocks. A sends a request to B and waits for
the reply, but B is waiting for a request from C who is waiting for A. Do you
block in the wrapper and wait for them to return? Or do you make the programmer
filter received messages manually? See b. for that option.

Jame



</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="00619" HREF="msg00619.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></STRONG>
<UL><LI><EM>From:</EM> "Jon A. Lambert" &lt;jlsysinc#ix,netcom.com&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00850.html">[MUD-Dev] World Building Page</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00852.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00704.html">[MUD-Dev] Re: Why modules? (Was: Inheritable modules)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00617.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00851"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00851"><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: Why modules? (Was: Inheritable modules)</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<ul compact>
<LI><strong><A NAME="00700" HREF="msg00700.html">[MUD-Dev] Re: Why modules? (Was: Inheritable modules)</A></strong>, 
Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Tue 03 Nov 1998, 04:31 GMT
<LI><strong><A NAME="00701" HREF="msg00701.html">[MUD-Dev] Re: Why modules? (Was: Inheritable modules)</A></strong>, 
Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Tue 03 Nov 1998, 04:49 GMT
</LI>
</LI>
<LI><strong><A NAME="00691" HREF="msg00691.html">[MUD-Dev] Re: Why modules? (Was: Inheritable modules)</A></strong>, 
Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Tue 03 Nov 1998, 00:23 GMT
<LI><strong><A NAME="00704" HREF="msg00704.html">[MUD-Dev] Re: Why modules? (Was: Inheritable modules)</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Tue 03 Nov 1998, 05:54 GMT
</LI>
</LI>
<LI><strong><A NAME="00851" HREF="msg00851.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
James Wilson <a href="mailto:jwilson#rochester,rr.com">jwilson#rochester,rr.com</a>, Sun 22 Nov 1998, 23:04 GMT
</LI>
</ul>
</ul>
<LI><strong><A NAME="00617" HREF="msg00617.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Sat 31 Oct 1998, 06:30 GMT
</LI>
<LI><strong><A NAME="00684" HREF="msg00684.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Jo Dillon <a href="mailto:emily#thelonious,new.ox.ac.uk">emily#thelonious,new.ox.ac.uk</a>, Mon 02 Nov 1998, 10:41 GMT
<UL>
<LI><strong><A NAME="00692" HREF="msg00692.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Vadim Tkachenko <a href="mailto:vt#freehold,crocodile.org">vt#freehold,crocodile.org</a>, Tue 03 Nov 1998, 00:24 GMT
</LI>
</UL>
</LI>
</ul>
</ul>
</ul>
<LI><strong><A NAME="00681" HREF="msg00681.html">[MUD-Dev] Re: DevMUD:  Inheritable modules</A></strong>, 
Jo Dillon <a href="mailto:emily#thelonious,new.ox.ac.uk">emily#thelonious,new.ox.ac.uk</a>, Mon 02 Nov 1998, 10:14 GMT
</LI>
</ul>
</ul>
</ul>
</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>