[MUD-Dev] Question about multithreaded servers

cg at ami-cg.GraySage.Edmonton.AB.CA cg at ami-cg.GraySage.Edmonton.AB.CA
Tue Jan 18 22:31:50 New Zealand Daylight Time 2000

[Greg Underwood:]

> >> > I suppose just by making a simple requirement that
> >> > all objects must be secured at the begining of the
> >> > script would take care of that.
> No, that's not true.  Just because you attempt to lock everything before
> you execute the script doesn't mean you avoid deadlocks.  Deadlocks occur
> when the following happens:
> 	Thread 1 - Get Lock 1 - ok
> 	Thread 2 - Get Lock 2 - ok
> 	Thread 1 - Get Lock 2 - block
> 	Thread 2 - Get Lock 1 - block

Perhaps the original writer was assuming that all the locks are acquired
at once. An example of that is the SysV locking stuff in some versions of
UNIX. It's ugly as sin, but essentially allows you to do a whole mess of
lock operations all at once, atomically.

> BTW, I had it realease the Locks in reverse order, simply to avoid minor
> thrashing.

I hadn't thought of that - I'll have to go check the stuff at work. I
likely did it reverse order, just because it looks better to me, but
possibly not always. Thanks for the tip!

Don't design inefficiency in - it'll happen in the implementation.

Chris Gray     cg at ami-cg.GraySage.Edmonton.AB.CA

MUD-Dev maillist  -  MUD-Dev at kanga.nu

More information about the MUD-Dev mailing list