[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

12248: RE: [MUD-Dev] Question about multithreaded servers

[Full Header] [Plain Text]
From: cg@ami-cg.GraySage.Edmonton.AB.CA
Newsgroups: nu.kanga.list.mud-dev
Date: Tue, 18 Jan 2000 22:31:50 -0700
Organization: Kanga.Nu
[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@ami-cg.GraySage.Edmonton.AB.CA
               http://www.GraySage.Edmonton.AB.CA/cg/



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