Re: Threads?

From: George (greerga@CIRCLEMUD.ORG)
Date: 01/26/98


On Tue, 27 Jan 1998, Nudd ap Mawr wrote:

>:Actually, yes I did.  The only real advantage in the way I implemented it
>:is that if your MUD gets stuck in an infinite loop or something takes too
>:long (like 2.1 billion dice rolling), the processing thread can be killed.
>:Then it restarts the processing again, but of course, the world may have
>:some inconsistency in it after doing that depending on when it loops.  The
>:way I did it is the only way I can think of, you cannot have multiple
>:processing threads because of the 4 global buffers.  I basically split it
>:into 'Network I/O' and 'Character Processing' with a backward compatible
>:option if thread creation fails.
>
>Actually you could get around this by using a mutex lock on the global
>variables.  Just put a lock infront of all of the critical sections, and
>release the lock when it is safe for those global variables to be
>overwritten.

Locking wasn't the idea of the patch, it was to use threads as easy as
possible. :)  I'm currently doing a locking implementation (although I'm no
locking expert) which will show up in a testing/ directory later.

>As far as threads go, probably the best candidate (sp?) for spawning of
>threads would be the ident lookup or dns name resolving.  Any other

That would be a nice use for it, too bad the ident package isn't part of
stock CircleMUD or I probably would.  The DNS query does sound useful.

>threads probably won't help much (ie. hard to document the
>benefits) unless you are running on a multi-processor type system.

It'd be nice for processing players, the thread just sleeps until data
shows up in the input queue and processes it.

>Basically, with threads you just have to be careful that variables that
>can be used by more than one thread don't get stomped on. And mutex locks
>are the solution for that.

Working on it.

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST