1999Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] Re: Sockets and fibers -->
<!--X-From-R13: "Qnyvona Fverfvnf Rnexybpx" <pnyvonaNqnexybpx.pbz> -->
<!--X-Date: Wed, 20 Jan 1999 10:41:00 &#45;0800 -->
<!--X-Message-Id: 009301be44a3$ee058610$55e5edd0@dev&#45;18.chilisoft.com -->
<!--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: Sockets and fibers</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:caliban#darklock,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="msg00227.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00229.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00221.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00239.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00228">Author</A>
&nbsp;|&nbsp;<A HREF="#00228">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00228">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: Sockets and fibers</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: &lt;<A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A>&gt;</LI>
<LI><em>Subject</em>: [MUD-Dev] Re: Sockets and fibers</LI>
<LI><em>From</em>: "Caliban Tiresias Darklock" &lt;<A HREF="mailto:caliban#darklock,com">caliban#darklock,com</A>&gt;</LI>
<LI><em>Date</em>: Wed, 20 Jan 1999 10:36:44 -0800</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>
-----Original Message-----
From: Adam J. Thornton &lt;adam#phoenix,Princeton.EDU&gt;
To: mud-dev#kanga,nu &lt;mud-dev#kanga,nu&gt;
Date: Wednesday, January 20, 1999 10:02 AM
Subject: [MUD-Dev] Re: Sockets and fibers


&gt;On Wed, Jan 20, 1999 at 09:11:06AM -0800, Caliban Tiresias Darklock wrote:
&gt;&gt; Has anyone here looked at the possibilities of spawning a single thread
&gt;&gt; which handles sockets and then using Microsoft's "fibers" to handle
&gt;&gt; individual sockets? How much of the one-thread-per-socket problem would
be
&gt;&gt; solved by this? With the speed of modern computers, what are the real
&gt;&gt; problems with just serialising the socket handling -- one thread with all
&gt;&gt; the sockets, servicing each socket in turn for some small time slice?
&gt;&gt;
&gt;&gt; Yes, I know, writing MUD servers under Windows is Bad. Granted. All the
&gt;&gt; same. ;)
&gt;
&gt;How would this differ from a poll-and-select() model under a Real OS?


By poll-and-select I assume you mean the standard "port concentrator" type
thing where you have a big array of sockets and just iterate through it
looking for recv() data and sending data where necessary. This was sort of
my final question; is that really a bad thing? I mean, I could handle 16
14.4 modems under DOS on a 286 running ZModem downloads on arbitrary files,
so theoretically I could do about the same with 40 56K lines on a P166, but
hopefully the Pentium is even faster than that and could handle a lot more.
Furthermore, downloads are protracted operations, which I don't really need
to do, so I should be able to handle even more folks. Plus I'm a better
programmer now than I was in '91. ;)

As far as a Real OS goes, I'm designing under Windows primarily because it's
going to be easier to port *from* Windows later. (Lacking a user interface,
this is a lot easier than your average Windows-to-other port.) I'm intending
to separate all the O/S dependencies into two files; one to handle
connections and send/recv (I always have to correct "xmit" to "send" when I
talk about that) and one to handle access to files and resources on the
server. Everything else will be straight C using the standard library, and
will not interact with the user or the network in the slightest other than
through a simple command/response API.

Hopefully this will mean that given the two hardware-specific files, anyone
who knows the target architecture can rewrite them so they work under that
machine, and we can drop them in and recompile. In practice, there will
probably be other problems that need to be addressed, and it's likely that
some sort of conflict will arise between two O/S platforms eventually. I
anticipate the major platforms will be Linux, Solaris, BSDi, and Windows;
starting under Windows will probably leave me room to spare on the others.
(With Windows in the mix, of course, the code must be 64-bit safe just in
case of an Alpha market.)

&gt;I suppose this really turns into a request about what a fiber is.

Per MS docs: "A fiber is a lightweight thread that is manually scheduled.
Specific fiber APIs include: ConvertThreadToFiber() CreateFiber()
DeleteFiber() GetCurrentFiber() GetFiberData() SwitchToFiber()"

Yeah, I don't get it either. Furthermore, MS adds:

"Fibers are designed to be employed by a single-threaded application, in
which case the leak will never occur. However, if threads with fibers are
started and terminated repeatedly, this can cause accumulation of memory
leaks and will eventually cause the process to run out of memory."

This doesn't bother me overly, since (given the details I've omitted) it's a
simple matter of never ignoring a return value and never discarding a
pointer without freeing its associated data, both of which I am rather anal
about. But what really disturbs me is the idea that fibers are supposed to
be used by a single-threaded application, evidently making it an
almost-multithreaded application. I don't get that at all. I may be looking
at an ad-hoc solution to a very specific issue which I don't have. According
to the above, you would theoretically be safe if you had multiple threads
but only one of them had fibers and it was never terminated until the end of
the program anyway.

| Caliban Tiresias Darklock            caliban#darklock,com
| Darklock Communications          <A  HREF="http://www.darklock.com/">http://www.darklock.com/</A>
| U L T I M A T E   U N I V E R S E   I S   N O T   D E A D
| 774577496C6C6E457645727355626D4974H       -=CABAL::3146=-




</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="00241" HREF="msg00241.html">[MUD-Dev] Re: Sockets and fibers</A></strong>
<ul compact><li><em>From:</em> J C Lawrence &lt;claw#under,engr.sgi.com&gt;</li></ul>
<li><strong><A NAME="00239" HREF="msg00239.html">[MUD-Dev] Re: Sockets and fibers</A></strong>
<ul compact><li><em>From:</em> "Adam J. Thornton" &lt;adam#phoenix,Princeton.EDU&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00227.html">[MUD-Dev] Re: Sockets and fibers</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00229.html">[MUD-Dev] Re: Thoughts</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00221.html">[MUD-Dev] Re: [DevMUD] Re: From Devmud: Database module, draft 3</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00239.html">[MUD-Dev] Re: Sockets and fibers</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00228"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00228"><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: META: list "peerage"</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00293" HREF="msg00293.html">[MUD-Dev] Re: META: list "peerage"</A></strong>, 
Bruce Mitchener, Jr. <a href="mailto:bruce#puremagic,com">bruce#puremagic,com</a>, Tue 26 Jan 1999, 21:06 GMT
</LI>
<LI><strong><A NAME="00453" HREF="msg00453.html">[MUD-Dev] Re: META: list "peerage"</A></strong>, 
Sayeed <a href="mailto:yu219121#YorkU,CA">yu219121#YorkU,CA</a>, Thu 18 Feb 1999, 18:07 GMT
</LI>
</ul>
</LI>
<LI><strong><A NAME="00222" HREF="msg00222.html">[MUD-Dev] Re: ADMIN: List server and Kanga.Nu host changes</A></strong>, 
Koster, Raph <a href="mailto:rkoster#origin,ea.com">rkoster#origin,ea.com</a>, Thu 21 Jan 1999, 00:04 GMT
<LI><strong><A NAME="00221" HREF="msg00221.html">[MUD-Dev] Re: [DevMUD] Re: From Devmud: Database module, draft 3</A></strong>, 
Greg Connor <a href="mailto:gconnor#nekodojo,org">gconnor#nekodojo,org</a>, Wed 20 Jan 1999, 23:58 GMT
<LI><strong><A NAME="00228" HREF="msg00228.html">[MUD-Dev] Re: Sockets and fibers</A></strong>, 
Caliban Tiresias Darklock <a href="mailto:caliban#darklock,com">caliban#darklock,com</a>, Wed 20 Jan 1999, 18:41 GMT
<UL>
<LI><strong><A NAME="00239" HREF="msg00239.html">[MUD-Dev] Re: Sockets and fibers</A></strong>, 
Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Thu 21 Jan 1999, 02:27 GMT
</LI>
<LI><strong><A NAME="00241" HREF="msg00241.html">[MUD-Dev] Re: Sockets and fibers</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Thu 21 Jan 1999, 04:01 GMT
<UL>
<LI><strong><A NAME="00243" HREF="msg00243.html">[MUD-Dev] Re: Sockets and fibers</A></strong>, 
Jon A. Lambert <a href="mailto:jlsysinc#ix,netcom.com">jlsysinc#ix,netcom.com</a>, Mon 25 Jan 1999, 02:00 GMT
</LI>
</UL>
</LI>
</UL>
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00295" HREF="msg00295.html">[MUD-Dev] Re: Sockets and fibers</A></strong>, 
Dr. Cat <a href="mailto:cat#oldzoom,bga.com">cat#oldzoom,bga.com</a>, Tue 26 Jan 1999, 21:56 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>