TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JERRY COFFIN
from: DARIN MCBRIDE
date: 1997-08-25 08:26:00
subject: volatile objects?

 -=> Quoting Jerry Coffin to Darin Mcbride
 DM> I'd post it, but the hand-coded queue uses OS/2 mutex's.  Mind you, if
 DM> I posted the entire class hiearchy, anyone who wanted to convert the
 DM> one mutex class to Win32 could, and the rest of the class would work
 DM> just fine.  :-)  A semaphore, in this class hiearchy, needs to:
 DM>    Create (publically, based on a semaphore name - not used by my
 DM> queues)
 DM>    Create (privately, without a semaphore name)
 DM>    Claim (optionally with a timeout to wait for the semaphore to
 DM> become available)
 DM>    Release
 DM>    Close
 DM>    Tell if the current thread has it claimed (note that the same
 DM> object can be used by multiple threads in the same process)
 DM>    Tell if the semaphore name (in the public create) is valid
 
 DM> If this is possible in Win32, I can post what I have for OS/2... :-)
 JC> As you doubtless expect, Win32's mutexes are similar enough to OS/2's
 JC> that all this should be pretty trivial to port.  In fact, I did
 JC> something like this a long time ago, with both OS/2 and Win32
 JC> variants: 
 JC> // event.h
Yes, I expected it, having worked with them almost a year and a half ago...
:-)
I'm unsure if you realize it, but events and semaphores are significantly
different... :-)
 JC> OS2(DosCreateMuxWaitSem(NULL, &hMux, NumThreads, SemRecords);)
 JC> Hmm...something looks wrong with the call to DosCreateMuxWaitSem,
 JC> though my memory of OS/2 programming is distant enough that I'm not
 JC> sure about that.  It may have gotten mangled some time or other, as
 JC> this has been on the hard-drive a LONG time, an the OS/2 part of it
 JC> hasn't been compiled in years.
The only thing that looks wrong with it to me is the fact that altering
SemRecords on the fly may or may not be supported - it's not documented
anywhere that you can do this.  In fact, since it does not explicitly say
that the memory for the SemRecords must live as long as the hMux it is being
put into, I'd be strongly suspicious about the above code.
So, is this a "go ahead and post your thread-safe [?] OS/2-based templated
circular queue"?  :-)
(Win32 could likely get away with just using Critical Sections, but some of
the Semaphore class could only be replicated via undocumented peeking into
the CRITICALSEMAPHORE[?] structure since there is no other way that I saw to
determine who currently owns the semaphore.  However, it would not support
the public creation for "full" compliancy to the class structure I created,
although it would work for this case.)
... I am Microsoft of Borg.  The superiority of other products is irreleva
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.