[MUD-Dev] Re: Sockets and fibers

J C Lawrence claw at under.engr.sgi.com
Wed Jan 20 20:01:33 CET 1999


On Wed, 20 Jan 1999 10:36:44 -0800 
Caliban Tiresias Darklock<caliban at darklock.com> wrote:

> From: Adam J. Thornton

>> 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()"

>From a MUD server viewpoint fibers are actually pretty obvious:
they are threads that the application itself handles the scheduling
for.

Consider the typical MOO or ColdX:

  There are various verbs etc which are executing in parallel.  In
order to preserve responsiveness the server itself, multi-threads
the verb executions.  It does this by allocating a processer time
per verb, and then cooperatively context switching over to the next
verb in the round-robin ring.  ie the server core cycles among the
verbs in an elegant and controlled manner, managing its own
deadlock/data-integrity issues etc for itself without any kernel
involvement.  

<<Yes, I know that this really isn't true, but its good enough.>>

Compare this to more typical threads, such as pthreads , or threads
under OS/2 or NT.  

  There threads are actually almost independant processes except for
the fact that they share a data segment.  Further, the threads don't
context shift cooperatively, but instead are scheduled by the kernel
and context shift preemptively.  In this model threads are really
stand alone beasts that are launched in parallel with the current
execution, and then left to more or less run on their own (minus
enforced synchronise points etc).  With fibers, the application
itself manages all its internal "threading", and so does __ALL__ the
dirty work.

What does NT's implementation of fibers give you above the simple
and fairly obvious cooperative task switching commonly used in MUD
servers?  I have no idea.  I suspect that it mostly gives you a
uniform (?) interface to the concept with some documented
behaviours.

--
J C Lawrence                              Internet: claw at kanga.nu
(Contractor)                             Internet: coder at kanga.nu
---------(*)                    Internet: claw at under.engr.sgi.com
...Honorary Member of Clan McFud -- Teamer's Avenging Monolith...




More information about the mud-dev-archive mailing list