1998Q3/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine -->
<!--X-From-R13: "Fbqq Znve" <gynveNznvymbar.pbz> -->
<!--X-Date: Fri, 17 Jul 1998 22:18:10 &#45;0700 -->
<!--X-Message-Id: 199807180516.WAA01095#hawk,prod.itd.earthlink.net -->
<!--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: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Eng</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:tlair#mailzone,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="msg00247.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00249.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00661.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00249.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00248">Author</A>
&nbsp;|&nbsp;<A HREF="#00248">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00248">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</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>" &lt;<A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A>&gt;</LI>
<LI><em>Subject</em>: [MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</LI>
<LI><em>From</em>: "Todd Lair" &lt;<A HREF="mailto:tlair#mailzone,com">tlair#mailzone,com</A>&gt;</LI>
<LI><em>Date</em>: Sat, 18 Jul 1998 01:19:36 +0000</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 Fri, 17 Jul 1998 19:51:11 -0600, Chris Gray wrote:

&gt;[Todd Lair:]
&gt;
&gt; &gt;Now, as far as the polling for both types of sockets, I'm wondering if there isn't a more 
&gt; &gt;efficient way than what I'm doing.  What I'm doing is using select, however, I'm only 
&gt; &gt;setting the single bit for the the descriptor in question for all three fd_sets.  This seems 
&gt; &gt;like a big mistake to me, since I imagine, as the descriptors get larger in number, that the 
&gt; &gt;select call has to see if each bit is set for the lower descriptor numbers till it gets to the 
&gt; &gt;single set one.
&gt;

&gt;[Chris Gray:]
&gt;
&gt;I didn't quite follow all of that, but I'll ask this question: where
&gt;does your server spend its time waiting if it has nothing to do? Mine
&gt;spends its time in a single 'select' call, which contains the fd-bits
&gt;for the main connection socket, and all client sockets. I'm not
&gt;multi-threaded, so that is easy for me to do.

Ok, maybe I should start from the beginning.  I have my
"event engine" set up as an array of link lists.  The
engine also maintains a variable called current which is
the current index into that array representing the current
tick.  The size of the array represents the largest number
of ticks in the future an event can be scheduled.  When a
client requests an event to be added to the engine, the
client passes the number of ticks (which has to be less
than the size of the engine's array) that need to transpire
before the event is ripened.  The engine uses this number +
current to figure out its place in the array (wrapping when
going past the physical length of the array).  Each tick,
current is incremented (again wrapping to index 0 when
current is equal to size of array).  After current is
incremented, all events in that link list are removed and
executed.  Between ticks, the engine uses select to "sleep"
for the time remaining for this tick.  If there were no
events executed, the sleep lasts the full tick time.  I
wake up every tick, increment current, and see if there are
any events in current's link list.

Each player and the master socket, gets its own individual
event associated with it.  When this type of event ripens,
it means that this single socket needs polling to see if it
has input, output, or an exception.  read: not all the
sockets, but the one.  My question again, is how should I
go about determining the read, write, exception status. 
Currently, I'm using select, setting a single bit in each
of the fd_sets for the descriptor.  This doesn't seem ideal
to me, since over time, the descriptors get higher in
number value, and the select call has to scan the fd_sets
to see where the single bit is set in each of the sets.

I was wondering if I should just use recv (possibly passing
the the peek parameter) to determine the status of the
descriptor that needs to polled.  I was wondering what
returns I need to worry about, and if this would be a much
more efficient method opposed to the select call on the
single descriptor.

&gt;What is it that "ripens" your events to trigger the polling? In general
&gt;polling (as opposed to calling the 'poll' SysV socket call), is a bad
&gt;idea, since your CPU is busy doing things without accomplishing much.
&gt;Polling is used in some circumstances in order to get the absolute
&gt;minimum latency, but that is usually in situations where the CPU is
&gt;dedicated, or when what it is waiting for is guaranteed to be ready in
&gt;a very short period of time.

I've been using polling as a term to describe the process
of determining whether or not the descriptor has read,
write, or exception status.  Sorry for the confusion.

&gt;My goal is that when there is nothing for my server to do, it will use
&gt;no CPU time at all. Now, the NPC's will be doing things, but in the
&gt;intervals when none of them is active, the server should be idle.

I hope mine will do the same.  Minus the CPU time needed to
check whether there is anything in the current's link list,
processing events, my server will sleep.

Todd



</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="00249" HREF="msg00249.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>
<ul compact><li><em>From:</em> oliver#jowett,manawatu.planet.co.nz</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00247.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engin</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00249.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00661.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00249.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00248"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00248"><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: DBMS in MU*'s</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00675" HREF="msg00675.html">[MUD-Dev] Re: DBMS in MU*'s</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Wed 12 Aug 1998, 04:26 GMT
</LI>
</ul>
</ul>
</LI>
<LI><strong><A NAME="00250" HREF="msg00250.html">[MUD-Dev] Design Patterns for Concurrent, Parallel, and Distributed Systems</A></strong>, 
Alex Oren <a href="mailto:alexo#bigfoot,com">alexo#bigfoot,com</a>, Sun 19 Jul 1998, 08:32 GMT
<LI><strong><A NAME="00246" HREF="msg00246.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sat 18 Jul 1998, 01:51 GMT
<UL>
<LI><strong><A NAME="00661" HREF="msg00661.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Tue 11 Aug 1998, 17:32 GMT
</LI>
</UL>
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00248" HREF="msg00248.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Todd Lair <a href="mailto:tlair#mailzone,com">tlair#mailzone,com</a>, Sat 18 Jul 1998, 05:18 GMT
<UL>
<LI><strong><A NAME="00249" HREF="msg00249.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
oliver <a href="mailto:oliver#jowett,manawatu.planet.co.nz">oliver#jowett,manawatu.planet.co.nz</a>, Sat 18 Jul 1998, 06:27 GMT
<UL>
<LI><strong><A NAME="00269" HREF="msg00269.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Mon 20 Jul 1998, 15:57 GMT
<UL>
<LI><strong><A NAME="00273" HREF="msg00273.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
Oliver Jowett <a href="mailto:oliver#jowett,manawatu.planet.co.nz">oliver#jowett,manawatu.planet.co.nz</a>, Mon 20 Jul 1998, 21:51 GMT
<UL>
<LI><strong><A NAME="00277" HREF="msg00277.html">[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine</A></strong>, 
s001gmu <a href="mailto:s001gmu#nova,wright.edu">s001gmu#nova,wright.edu</a>, Tue 21 Jul 1998, 13:49 GMT
</LI>
</UL>
</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>