[MUD-Dev] Question about multithreaded servers
lemkef at execpc.com
Fri Jan 14 11:11:56 New Zealand Daylight Time 2000
Hello, First time post, but long time lurker :)
I'm mostly a hobbiest programmer, and like to tinker with various thing.
MUD desgin has facinated me for a very long time now. I'm having a bit of
a problem though I'm hoping will be fairly simple to solve..
I'm in the midst of redesigning a more simplistic server I've been working
on - it's nothing fancy, and basically something to play with - and
decided to go multi-threaded so that there won't be blocking and polling
and such. The design I have so far I think will work wonderful, except
for one problem..
The server is going to be very script-based, and I have a behavior/effect
model in mind that tests out great in theory, but the script layering it
requires is what's causing the problem:
Since most of the time, players will only be interacting with others in
the same area, I've decided to do one thread per area (area consisting of
a collection of rooms). Also one thread for client for rendering what
they see based on game events, and handling input and output to the
sockets. The problem is that the Area threads will be responsible for
telling the objects to process scripts, and I'll be needing commands to
get access to objects that may be in other area threads - usually not a
problem if locking is all proper - but I'm worried about deadlocks because
I want objects locked during the whole script so nothing can be changed on
me. Since object scripts can get out-of-area objects to play with, they
have to be locked for the rest of the script. If two objects (not in the
same area) lock themselves to run a script, and then each's script
attempts to secure the other.....
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
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.
Thanks a heap :)
MUD-Dev maillist - MUD-Dev at kanga.nu
More information about the MUD-Dev