[MUD-Dev] Re: lockless system - foolproof?

T. Alexander Popiel popiel at snugharbor.com
Mon Aug 31 07:40:10 CEST 1998


In message:  <E0zDMqj-0000QX-00 at mail.kanga.nu>
             J C Lawrence <claw at kanga.nu> writes:

>  Assume a SHOUT command that passes its argument to all players and
>NPCs.  The obvious (and actually fairly common) approach is something
>as follows:
>
>  for target in (players && NPCs)
>    deliver string
>
>This is an obvious high contention candidate as the working set by the
>end of the event will be extremely large.  A possible low-contention
>implementation, might be the following:
>
>    1) Logs an event X which does nothing collect a list of all
>players and NPC's (fairly trivial by traversing the child-list of the
>relevant root objects, thus having a working set of only two objects),
>and then, as part of its C&C logs further events, either one per
>target object, or one per small sub-set of target objects (lists are
>your friend).  This executes rapidly and has minimal contention.
>
>  2) The secondary logged events then run and deliver the string to
>the relevant player/NPC's, each with a total working set of only the
>target object, and thus minimal contention.  These execute extremely
>rapidly and have minimal contention.
>
>Of course this also means that your execution model had better be
>pretty efficient or you will spend all your time in the overhead of
>building and tearing down events rathr than executing them.

This sounds like it would open your game to event-order confusion.
Imagine someone holding an auction via shout... and two people
shout at nearly the same time.  Because of the separation of
different targets into different events, the auction master and
each of the shouters could be notified in different events.
Because of your parallel execution race-condition for C&C, they
could hear the shouts in different orders.  This'll lead to some
very nice flame festivals when the item under auction gets sold
to the "wrong" person...

  Cast: Auction master M, Bidder A, and Bidder B.

  Bidder A shouts "1500!" (event A0)
  Bidder B shouts "1500!" (event B0)
  Shout A0 gets broken up into AM, AA, AB
  Shout AB gets broken up into BM, BA, BB.
  AM passes C&C, M hears "A: 1500!", BM rescheduled.
  BB passes C&C, B hears "B: 1500!", AB rescheduled.
  BM passes C&C, M hears "B: 1500!".
  AA passes C&C, A hears "A: 1500!", BA rescheduled.
  AB passes C&C, B hears "A: 1500!".
  BA passes C&C, A hears "B: 1500!".
  M sells to A.
  B PKills M.

- Alex




More information about the mud-dev-archive mailing list