TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mike Bilow
from: Darin McBride
date: 1996-05-22 15:00:08
subject: Semaphores (16 & 32)

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

 MB> Semaphores accessed by the old 16-bit API calls use the
"\SEM\" names.

That's what I was afraid of.  :-/

 DM>         Since I'm using Watcom (10.6), I have the PRCP.INF
 DM> file which, handily, has DosCreateSem which wants to use
 DM> \SEM\ instead.  I thought, "Great!  I'll just use that!" 
 DM> Watcom's compiler tells me that these aren't in the header
 DM> files (the ones that come with Watcom, nonetheless!), so too
 DM> bad.  Ack!  Not in the Warp Toolkit headers either, it
 DM> seems.  I created the function prototypes, having noticed
 DM> that these functions were in OS2286.LIB, and linked with
 DM> that lib (in the 386 directory), but the linker complains
 DM> that they are undefined references.  Somehow I'm guessing I
 DM> need those, but...

 DM> Can anyone help me?

 MB> Well, you have several options.  You could write your 
 MB> program using the 16-bit OS/2 compiler included with 
 MB> Watcom C++, and then you be using the header files from 
 MB> \WATCOM\H\OS21X.  This would work, and would probably 
 MB> be reasonable for short, simple programs.

It's not that short, and definately not that simple.  :-/  I'm using the
STL to create massive arrays in memory, doing things with them, etc.  I
need the flat model to access megabytes of ram at a time.

 MB> Another approach would be to write the necessary 
 MB> function prototypes manually, including the "_far16" 

I have the prototypes *almost* done, but I'm not sure how to use the _far16
and _seg16 keywords.

 MB> and "_Seg16" extended keywords as needed.  See the 
 MB> User's Guide for more information about how to 
 MB> prototype and call a 16-bit function from 32-bit code.  
 MB> The compiler will generate the necessary thunk.

I've noticed a little bit on these, but _seg16 says it can't be used with
function prototypes.  I'm going to try _far16, though.  :-/

 MB> Yes, use mutex semaphore to enforce mutual exclusivity. 
 MB>  You can use the 16-bit semaphores for simplicity if 
 MB> you choose, rather than mix 16-bit and 32-bit 
 MB> semaphores.  You lose certain functionality with the 16-
 MB> bit semaphores, especially support for multiplex 
 MB> semaphores.

While I won't be using any advanced features of semaphores (yet), I want to
be used to using them rather than the 16-bit ones anyway.  :-)

 MB> There are extensive examples supplied with the Watcom 
 MB> C++ compiler, provided you chose to install them, in 
 MB> \WATCOM\SAMPLES\TOOLKT2X\C\SEMAPH.

I guess I didn't.  ;-)  However, I *have* installed the Warp toolkit from
DevCon 9, and it has a few semaphore examples.  :-)

 DM> Perhaps after I learn semaphores, I'll go on to
 DM> multi-threading.  :-)   

 MB> This stuff is not rocket science.  It just requires 
 MB> time and effort to learn.

I'm just taking the time and effort now... ;-)

Thanks, Mike.  I'll let ya know how using _far16 turns out... and if it
doesn't, perhaps you have a snippet of code as an example?  :-)


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