TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Doug Nazar
from: Darin McBride
date: 1996-05-28 22:12:04
subject: Semaphores (16 & 32)

DM>         I'm trying to block Sq386p.exe which uses \SEM\SQUISH\DEFAULT,
DM> however the Semaphores included in the Warp toolkit 
DM> want me to use \SEM32\
DM> to start.  Can I just use \SEM\ anyway?

 DN> The "/sem" prefix is used in 16 bit code as you have noticed.

Gotta learn _some_ stuff the hard way.  ;-)

DM> in the header files (the ones that come with 
 DN> Watcom, nonetheless!), so too
DM> bad.  Ack!  Not in the Warp Toolkit headers either, 
DM> it seems.  I created

 DN> They are in the 16bit headers (\watcom\h\os21x). Also 
 DN> in the 1.3 toolkit & the 16bit headers on the DDK.

Yup - but when I link with OS2286.LIB, the program can't even load.  :-/

DM> the function prototypes, having noticed that these functions were in
DM> OS2286.LIB, and linked with that lib (in the 386 directory), but the
DM> linker
DM> complains that they are undefined references.  
DM> Somehow I'm guessing I need
DM> those, but...

 DN> Most likely you have the calling convention wrong. You 
 DN> need to do something like

 DN> extern "C" {
 DN>    APIRET16 APIENTRY DosCreateSem(...);
 DN> }

APIENTRY16, actually.  But I finally got the calling stuff set up, but...
it still refuses to run.  :-/

 DN> Now that we've covered all that, here's the easy way to 
 DN> do it . Scott uses a DLL (SMSERIAL.DLL) to handle 
 DN> his serialization after a bit of work testing it here 
 DN> is a little util to use it.

Actually, seeing as I knew SQ386P was 32-bit, I knew he had to do it
somehow somewhere.  So, I found SMSERIAL.DLL, and a bit of investigation
showed that it had something to do with this.  I then emailed Scott.  :-)

However, I *know* that it is possible to do from 32-bit code somehow, as I
have a 32-bit program that uses both 16-bit and 32-bit semaphores... and
I'd like to figure out how.  :-}

 DN> void _Far16 _Pascal BbsSemSerialize(char * semaphoreName, char* dontKnow);

'dontKnow' is a string delemitating the name of an environment variable
that is permitted to override semaphoreName.

 DN>          rc = DosGetMessage(0, 0, msgBuf, 2048, 
 DN> errorNumber, "OSO001.MSG", &msgLen);

I actually used this so much in my code that I have a seperate function
that creates a 'String' object out of the msgBuf and returns it.  It then
allows a cerr << GetOSOErr(ulErrorNumber) << endl;.

However, your class looks a little more useful.  :-)

 DN> int main() { /*FOLD00*/

What OS/2 editor do you use that has folding?

Thanks, Doug.


--- Maximus/2 3.01
* Origin: Tanktalus' Tower BBS (PVT) (1:342/708)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1
@PATH: 342/5015 61 3615/50 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

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™.