TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: David Etheredge
from: Mike Bilow
date: 1995-04-02 01:50:52
subject: OS/2 programming tips ???

David Etheredge wrote in a message to All:

 DE> 1) I am writing a program for OS/2 that I only want one copy
 DE> to load. How can I detect whether or not a copy is already
 DE> loaded at runtime?

There are several ways to do this, but the easiest is to attempt to create
and request ownership of a semaphore with a predefined name when your
program starts and then release and close it when your program ends.   If
the semaphore is already owned when you request it with a time-out of zero,
then you can assume that another instance of your program is running.  You
obviously need to take some care in using a semaphore name that would not
be likely to collide with that used by another program.

 DE> 2) I know that OS/2 does not allow sharing IRQ's, Is there a
 DE> way around this? Surely, there is a way.

OS/2 fully supports sharing IRQs.  However, doing anything at all with IRQs
involves working at the device driver level.  Applications under OS/2 can
never touch IRQs directly.  Even in DOS sessions, where programs are
allowed to think they hook IRQs, a driver stack is actually going through
quite a lot of trouble to create the illusion.

 DE> 3) Are you allowed to use the 1ch timer in OS/2? If not, how
 DE> can you synchronize timed events to the tic counter?

Maybe you would get better answers if you backed up a bit and explained in
more broad terms what it is that you want to do.  There are numerous timer
APIs provided in OS/2, some such as DosSleep() based on CPU time, others
such as DosTimerXxxx() based on absolute time.

 DE> 4) CTRL-H in EPM will not bring up help on ANSI 'C'
 DE> functions such as printf() ( or anything not in the OS2.h
 DE> header set). Is this intentional, a flaw, or a setup
 DE> problem?

EPM is an editor, not an IDE.  It is pretty configurable, so I'm sure
someone else will have the answer to your question, although I don't.

 DE> 5) is there a way to do automatic unattended shutdown and
 DE> reboot?  

Yes, and it is undocumented.  The procedure is actually not simple, since
you have to do things very carefully and in a strict order, such as
shutting down the file system.  You also have to make sure you don't kill
your shutdown process, which requires a bit of special handling.  Why do
you want to do this?  Programmers should not assume that they own the
machine under OS/2, and doing things like shutting down the operating
system would be viewed as not being a good OS/2 citizen.

 DE> If there are any code examples out there, it would be
 DE> appreciated. 

Well, as I asked, what is it that you are trying to do?
 
-- Mike


---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 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™.