[MUD-Dev] Question about multithreaded servers

AR Schleicher ars at iag.net
Fri Jan 14 15:24:38 New Zealand Daylight Time 2000


----- Original Message -----
From: Fabian Lemke <lemkef at execpc.com>
> The only solution I can think of is to have a seperate thread for
> executing scripts, but 95% of the time scripts won't need to access
> out-of-area objects.
>
> Any ideas how this can be solved?  I'm somewhat new to multi-threading,
> but am pretty sure I have a solid grasp on it all, but I've little design
> experience in it.

While you're worried about deadlocks from using a locking mechanism, I think
it's the way to go.  You need to design your system so that a thread can
release all the locks it has if it fails to get one it wants.  Depending on
the details of your system, this may mean a) ok, record the locks I have,
release them all, and wait until I can get them all back at once, or b) ok,
I'll put that action on hold, and continue processing what I can in this
thread, and then I'll try that lock again next cycle through my loop.
(Which assumes the end of the cycle releases all the locks for a bit, so
that other threads can get them.)

There are other options (such as locking in a specific order) which can also
work, for some systems.

A warning regarding my advice, it's based on a server I wrote a little over
a year ago, and basically gave up on, due largely to the fact that I hadn't
thought this issue all the way through before coding, and had setup
situations where I could potentially deadlock.  Fixing it would have
required more time than I wanted to spend then,  so I never got around to
actually implementing my advice.  :)

AR Schleicher (Jerrith)
ars at iag.net





_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev



More information about the MUD-Dev mailing list