[MUD-Dev] Multi-threaded mud server.

David Bennett ddt at discworld.imaginary.com
Sun May 16 21:17:02 CEST 1999


On 5/16/99, at 8:42 PM, Ross Nicoll wrote: 

>Now, the tricky bit is making sure that the database is not being modified
>and read from at the same time (modifying the tree during a read could be
>seriously bad), and also that any particular object is not being modified
>and read from at the same time.
>
>Semaphores were the original plan, but as I understand it, this would
>require a new semaphore for each object. As we're looking at 10,000+
>objects, that's a _lot_ of semaphores.

Well...  You could do a system that only generated a semphore when it was
needed...  As in you have some nice bit you set in the structure for
reading/writing and another bit you set for being locked.  Then if it goes
to do a normal semphore unlock and it finds that a semaphore is needed it
grabs it correctly.  Or just waits on an event or something.

Or...  Hmmm...  You could have a pool of semaphores you grab from,
dynamically allocate them to the objects when needed and then release them
afterwards.  Actually, that is probably the easiest solution.  When you go
to access an object check to see if it has a semaphore, if not create one.
When you release, check to see if anyone is waiting on the semaphore, if
not release it...

You can also divide the objects up into groups and then do read locks and
write locks on the group as a whole.  Or (as is mentioned by Caliban)
divide the system up into tasks.

Wondering how much fluff is never enough,
David.



_______________________________________________
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