TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Stefan van der Walt
from: Mike Bilow
date: 1996-03-11 01:19:56
subject: Time Slicing and Detecting OS/2

Stefan van der Walt wrote in a message to Mike Bilow:

 MB> 3. Release timeslice.

 SvdW> Thanx.  This is a great help.  You do not know any routines
 SvdW> to determine the current software?  (Especially OS/2 - I got
 SvdW> a reply on that one but need more)

There are several ways to detect OS/2 from a DOS program, depending upon
what it is that you are trying to do and how careful you need to be.  The
simplest thing to do is to call the usual DOS service to get the DOS
version number, and OS/2 will return a DOS major version created by
multiplying its own major version by 10; for example, OS/2 1.x will show a
DOS process a major version of 10, and OS/2 2.x (including Warp, which is
internally OS/2 2.30) will show a major version of 20.

It is possible to fool this usual DOS version check in OS/2.  If the user
sets the program object to provide some fake version number to the DOS
program, then OS/2 will do so.  If the program is run from a virtual
machine boot as opposed to a more usual DOS session, then the version
number returned will be the version associated with the instance of DOS
running in the virtual machine.

If you really need to check if you are on OS/2, and you have to make sure
you will detect this even if you are running in a virtual machine boot or
if the user has specifically set up a fake version number, then it is
possible to do this using undocumented Int 2Fh calls from with a DOS
session on OS/2.

If all you are worried about is knowing how to release a timeslice, stick
to DPMI: it will work correctly under OS/2 DOS, Windows 3.x, Windows 95,
Windows NT, and even on recent versions of DESQview.

 SvdW> Thanx again.

 MB> know that DPMI services are available, you can release the timeslice
 MB> whenever you want. 

 SvdW> How often?

I suppose you can release the timeslice whenever your program is idle. 
This is not to be misinterpreted as a license to write polling loops in
programs to be run under OS/2, since these will have other bad effects
involving such things as memory paging even if the CPU is released.

 SvdW> PS You program in ASM?

I can, but I rarely need to do so these days.  I provided the information
in assembly format primarily because you did not say which language you
were using, and I wanted my reply to be language independent.
 
-- Mike


--- 
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 50/99 78/0 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 7877/2809
@PATH: 323/107 170/400 396/1 270/101 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™.