[MUD-Dev] Question about multithreaded servers

Ola Fosheim Grøstad <olag@ifi.uio.no> Ola Fosheim Grøstad <olag@ifi.uio.no>
Sat Jan 15 23:10:03 CET 2000


Nick Shaffner wrote:
> >but I'm worried about deadlocks because
> >I want objects locked during the whole script so nothing can be changed on
> >me.
> 
>     IMHO, this is the root of your problem (locking objects for the whole
> script).  By nature, deadlocks are far more likely to occur when you have
> entire objects locked, even when they don't need to be.  In general, you
> should strive to hold as few object locks as possible for as short a period
> as possible - though even then you will still get the occasional deadlock.

I don't get this.  Maybe I have misinterpreted something?  It is rather
obvious that if you acquire all the limited resources you need for the
rest of the script in one go (an atomic operation) then a deadlock is
impossible (provided that your script eventually terminates). 
Starvation is another issue, of course. 

I'm not convinced that message passing (events) alleviates the basic
synchronization problem, but you seemed to suggest that? Care to explain
how you would do this in an elegant and practical eventengine? Simple
example: "consume two different resources administered by two different
entities, but only if you can get both". It is obviously not to
difficult to come up with some solution to this simple example, but I
can't think of any attractive solution.

In a real-time programming environment I would assume that a rollback
scheme is the most attractive solution, basically because you cannot
prevent screw ups in a situation like that. You have to be able to cover
situations where a script doesn't terminate etc. Without rollback you
have to restrict yourself to a design where only trivial transformations
are possible. (non-trivial being custom transformations where the
consumption of one or more resources must result in the production of
some other resource for the universe to remain consistent). One obvious
advantage with a functional (transaction  like) approach is that you can
allow users more freedom and assert that the universe invariants are not
violated before committing them rather than limiting the basic operators
they have access to.

(btw, has "tupple spaces", such as Linda, been discussed on mud-dev
before?)

Ola.





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



More information about the mud-dev-archive mailing list