Unique id's

Jon A. Lambert jlsysinc at ix.netcom.com
Sun Apr 13 17:34:11 New Zealand Standard Time 1997

> From: coder at ibm.net
> To: Multiple Recipients of MUD Design Mailing List <mud-dev at null.net>
> Date: Sunday, April 13, 1997 12:16 PM
> >Ahh your ID has two parts.  I use something called a CriticalSection
> >object to block the ' id++; ' function.  Its very similar to a mutex,
> >except the reset occurs automatically upon leaving  the code section. 
> >Its supposed be slightly more efficient, but I believe its really a mutex
> >under the covers. I use it alot, all over the place. :-)
> Check into the base code for your CriticalSection.  I've seen far to many
> such blobs whose definition of a critical section is that it is the ONLY
> thread in the application allowed to execute for the duration.  <shudder> 
> (This how OS/2 and Windows handle their "critical section" API's, and I've
> seen something similar in a library that shall remain nameless for SunOS).
Ah not to worry.  The following is pasted from my help file.  I will of course
check it out at the debug level to make certain.


For the threads of a single process, critical-section objects provide another (and slightly more efficient) means of
synchronization. A critical section is used like a mutex to enable only one thread at a time to use the protected resource. A
thread uses the EnterCriticalSection function to request ownership of a critical section. If it is already owned by another thread,
the requesting thread is blocked. After it receives ownership, the thread is free to use the protected resource. The execution of
the other threads of the process is not affected unless they attempt to enter the same critical section. 

--end cut--


More information about the MUD-Dev mailing list