1998Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Dynamic Loading of Modules -->
<!--X-From-R13: @vxynf Syzdivfg <q97ryzNqgrx.punyzref.fr> -->
<!--X-Date: Fri, 20 Mar 1998 11:39:55 +0000 -->
<!--X-Message-Id: Pine.SOL.3.96.980320070741.7537A&#45;100000#licia,dtek.chalmers.se -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199803191942.LAA34273#under,engr.sgi.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Dynamic Loading of Modules</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:d97elm#dtek,chalmers.se">
</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="msg00786.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00788.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00764.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00797.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00787">Author</A>
&nbsp;|&nbsp;<A HREF="#00787">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00787">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Dynamic Loading of Modules</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI>
<LI><em>Subject</em>: Dynamic Loading of Modules</LI>
<LI><em>From</em>: Niklas Elmqvist &lt;<A HREF="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</A>&gt;</LI>
<LI><em>Date</em>: Fri, 20 Mar 1998 12:39:51 +0100 (MET)</LI>
<LI><em>Reply-To</em>: Niklas Elmqvist &lt;<A HREF="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</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 Thu, 19 Mar 1998, J C Lawrence wrote:
&gt; On Tue, 24 Feb 1998 00:12:50 PST8PDT 
&gt; Niklas Elmqvist&lt;d97elm#dtek,chalmers.se&gt; wrote:
&gt; &gt; As I said earlier, I am aiming to decouple the actual core server
&gt; &gt; from the world processing routines. Ideally, the main server would
&gt; &gt; not even *know* it is running a MUD, it would be sort of a
&gt; &gt; general-purpose core...
&gt; 
&gt; You have loosely described the general purpose network server espoused 
&gt; by such as the ColdX project.  Cold is currently being used to server
&gt; MUDs, web sites, as an SQL database frontend (for web) and otehr
&gt; purposes.

Ahh, *that* is what Cold does. I've checked out cold.org a couple of times
but never really understood what it all was supposed to do -- it was so
very generic. Nice to see that one's thinking parallells that of other
people, though.

&gt; &gt; ...and all the functionality such as DB
&gt; &gt; management, socket I/O and AI would be implemented in free-standing
&gt; &gt; modules separate from the main executable (at least, I envisioned
&gt; &gt; this in the beginning). 
&gt; 
&gt; Which abstraction is deeper than Cold (or any other that I know of)
&gt; has attempted.

Of course, this abstraction comes at a price. Since the modules are very
decoupled and don't know anything about each other's existence, I need a
decoupled way of allowing them to exchange information. I envision this
mechanism as a request chain on which the individual modules can put their
ear to and listen on (alternatively, register their interest in different
kinds of requests to a request manager or something). Whenever a request
comes along of the desired type, the module snags it and processes it
(this request may be a buffer of unprocessed text from the socket I/O
module, or a user command from the interpreter or whatever). The module
would then possibly emit a request on its own on the request chain to
pass along its processed information (a parser would emit parsed text, an
interpreter a user command, a magic module an area effect, etc). This way,
I have a decoupled intermodule communications chain. 

As I said earlier, the problem I can see with all this is that it is not
going to be very computationally efficient -- but it is neat, IMO. That
is, for every command issued by the user, for example, I will need a
potentially large number of requests passed between different modules: 
	socket I/O =&gt; parser =&gt; interpreter =&gt; user command handler
and so on. Also, I expect that using C++ instead of C (like I did in my
earlier effort PirateMUD) will also decrease performance somewhat,
although I have no idea about how much. No matter. It all just means I'm
going to need a bigger server. &lt;cough&gt;

&gt; &gt; I mentioned this to a RL friend of mine, and
&gt; &gt; he pointed out that it all sounded very much like conventional OS
&gt; &gt; architecture, especially like the module system of Linux kernels. 
&gt; 
&gt; I should point out that the original version of Shades was written to
&gt; run on a DEC PDP-11.  In truth Hazeii hacked RMS to be the MUD (mainly 
&gt; the command interpreter) so that effectively the OS _was_ the MUD.  

Sounds like fun. :) Hey, everybody, why don't we all take the Linux kernel
and modify it to become MudLinux! Or we could call it Mudix or
something...

&gt; &lt;bow&gt; Cute.  Note that the vtable handling could easily get very
&gt; messy, especially if you abstract heavily, go for multiple
&gt; inheritance, or any of the nastier virtual structures. 

Well, the vtable handling is hidden from me by the compiler, so hopefully
I won't have to deal with that. I *do* have to deal with potential
performance loss, though, I expect.

&gt; What platform/compiler BTW?

This on a x86 (Pentium II, as a matter of fact) running Linux 2.something
using the gcc/g++ 2.7.2.2 compiler... I've heard that gcc 2.8.0 and egcs
fixes some nasty problems in gcc 2.7.2.2 (especially when it comes to
templates, the STL string class header will not compile if it is not the
first STL #include in a source file, for example), so I am thinking about
upgrading. Furthermore, I have no idea whether the dynamic linking scheme
works on other platforms than Linux -- it *should* work on SunOS and
Solaris (and possibly other Unices) since the dl*() functions are derived
from Sun.

&gt; &gt; Incidentally, a
&gt; &gt; friend (the one mentioned above) later reported that this is
&gt; &gt; impossible in Windows-style DLLs.
&gt; 
&gt; Yup.  The features behind this working are that the name mangling and
&gt; vtable manipulations remained consistent.

I actually ran into trouble with name mangling when I at first attached a
module to the core binary and tried to call a factory function called (not
surprisingly) foo() in the module which would return a bClass (a class 
secretly inherited from aClass) object. Of course, g++ had mangled foo()
into something like foo_fV (I discovered this with the nm utility). By
instead doing
	extern "C" aClass *foo(void) 
I prevented this name mangling.

&gt; &gt; If the base classes are correctly
&gt; &gt; implemented, the core will never even have to be recompiled and thus
&gt; &gt; never rebooted (not accounting for fatal bugs, that is &lt;g&gt;)!
&gt; 
&gt; You're going to need a very clean connect/disconnect model (and likely
&gt; require single-threading unless you want to be excessively
&gt; entertained) to ensure that no code points are in or about to enter a
&gt; modeule which you wish to remove, or retain state data, or
&gt; back-references (such as instances) for the about-to-be-removed   
&gt; module.

Haven't thought of this, but I was probably going to implement this
single-threaded nonetheless. As for the connect/disconnect model, this
will probably be handled by a special module handler which is part of the
core functionality of the server executable. This handler would ensure
that all references to a module are cleanly removed when disconnecting it.
Because of the decoupled module architecture, the core server is the
*only* part of the MUd which knows about a specific module and its
methods, and it only keeps a reference and knows the base class of the
module at that (which could be a class called BaseModule or something).
All data flow is handled through the request chain mentioned above, as
well as through events in the event list. Therefore, I would never have
any problems of having another module keeping invalid references to a
detached module -- the only effect of a detached module would be that it
would no longer catch requests on the request chain (possibly leading to
the request being unhandled, which of course would result in a system
error or something like that, but would not hang the server). 

&gt; J C Lawrence                               Internet: claw#null,net 
&gt; (Contractor)                               Internet: coder#ibm,net
&gt; ---------(*)                     Internet: claw#under,engr.sgi.com
&gt; ...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...

-- Niklas Elmqvist (d97elm#dtek,chalmers.se) ----------------------
"You can't trample infidels when you're a tortoise. I mean, all you 
 could do is give them a meaningful look."	 
	- Terry Pratchett, Small Gods


</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="00850" HREF="msg00850.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></strong>
<ul compact><li><em>From:</em> J C Lawrence &lt;claw#under,engr.sgi.com&gt;</li></ul>
<li><strong><A NAME="00797" HREF="msg00797.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></strong>
<ul compact><li><em>From:</em> Greg Munt &lt;greg#uni-corn,demon.co.uk&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00764" HREF="msg00764.html">Re: [MUD-Dev] Dynamic Loading of Modules (was: Back on the list)</A></STRONG>
<UL><LI><EM>From:</EM> J C Lawrence &lt;claw#under,engr.sgi.com&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00786.html">3D engines for MUDs</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00788.html">Re: [MUD-Dev] 3D engines for MUDs (was: The MLI Project)</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00764.html">Re: [MUD-Dev] Dynamic Loading of Modules (was: Back on the list)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00797.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00787"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00787"><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>Re: [MUD-Dev]  Back on the list</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00564" HREF="msg00564.html">Re: [MUD-Dev]  Back on the list</A></strong>, 
coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 23 Feb 1998, 19:13 GMT
<UL>
<LI><strong><A NAME="00574" HREF="msg00574.html">Dynamic Loading of Modules (was: Back on the list)</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Tue 24 Feb 1998, 08:19 GMT
<UL>
<LI><strong><A NAME="00575" HREF="msg00575.html">Re: [MUD-Dev]  Dynamic Loading of Modules (was: Back on the list)</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Tue 24 Feb 1998, 08:42 GMT
</LI>
<LI><strong><A NAME="00764" HREF="msg00764.html">Re: [MUD-Dev] Dynamic Loading of Modules (was: Back on the list)</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Thu 19 Mar 1998, 19:42 GMT
<UL>
<LI><strong><A NAME="00787" HREF="msg00787.html">Dynamic Loading of Modules</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Fri 20 Mar 1998, 11:39 GMT
<UL>
<LI><strong><A NAME="00797" HREF="msg00797.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></strong>, 
Greg Munt <a href="mailto:greg#uni-corn,demon.co.uk">greg#uni-corn,demon.co.uk</a>, Fri 20 Mar 1998, 21:53 GMT
</LI>
<LI><strong><A NAME="00850" HREF="msg00850.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Mon 23 Mar 1998, 19:14 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00800" HREF="msg00800.html">Re: [MUD-Dev]  Dynamic Loading of Modules (was: Back on the list</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Sat 21 Mar 1998, 00:54 GMT
<UL>
<LI><strong><A NAME="00806" HREF="msg00806.html">Dynamic Loading of Modules</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Sat 21 Mar 1998, 10:05 GMT
</LI>
</UL>
</LI>
</UL>
</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>