[MUD-Dev] Multi-threaded mud server.
Jon A. Lambert
jlsysinc at ix.netcom.com
Sun May 30 00:29:39 CEST 1999
On 28 May 99,, Ross Nicoll wrote:
> On Sun, 16 May 1999, David Bennett wrote:
>
> > >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.
> Good idea, but unfortunately it's still possible two processes to
> simultaneously do the check, find no semaphore, and both to then try
> allocating a semaphore, at the same time. Which would just result in a
> mess, really...
>
I'm not sure what synchronization objects you have available, but...
I use Event objects when waiting for external signals (sockets and disk).
And I use Critical Sections liberally in classes, especially in Factory
classes to ensure that exclusive access is obtained until object
constructors complete. I had all kinds of problems in this area, BTW.
You might not, but it's something to look closely at. :)
I also use a variation on Critical sections called Metered Critical
Sections (there's a document describing them at www.msdn.com). Anyway
the variation, I most frequently use allows multiple readers OR one
exclusive writer.
Mutexes and Semaphores are the most expensive synchronization objects
on my platform. YMMV
I also make use of InterlockedIncrement, InterlockedDecrement, and
InterlockedExchange. What they do is allow you to provide some very
lightweight non-interruptable function access to shared variables.
--
--* Jon A. Lambert - TychoMUD Email:jlsysinc at ix.netcom.com *--
--* Mud Server Developer's Page <http://pw1.netcom.com/~jlsysinc> *--
--* To fight the empire is to be infected by its derangement. Whosoever *--
--* defeats part of the empire becomes the empire; it proliferates like a *--
--* a virus... thereby it becomes its enemies." -- P.K. Dick *--
_______________________________________________
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