TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Eric Theriault
from: Peter Fitzsimmons
date: 1995-01-07 00:46:18
subject: Time Slicing...

ET> What is the proper Time Slicing and detection function 
 ET> for all versions of OS/2?

I assume you are talking about for a DOS program?  (not really on topic
here,  but I'll let it by since you are trying to be os/2-friendly (if you
were REALLY friendly,  you'd write a native os/2 version of your program
:-)).

*OFFICIAL* OS/2 detection technique:  query the "DOS" version. 
If it is version 10.x,  it is OS/2 1.x.  If it is version 20.x,  it is
version 2.x (Note that despite what the box says,  Warp is OS/2 2.30).

    Many programmers think this is too simple of a solution (dos version
    check),  but it IS the official MS/IBM way to detect OS/2.

Releasing Slices:  Under OS/2 1.x this is kinda complicated so I am not
going to get into it unless you really want an answer.

Under OS/2 2.x (including warp),  do it the same way you would under windows 3.x:

    mov ah, 1680h
    int 2fh

    (note that a bug in OS/2 2.1ga prevented this from working).

A highly unofficial OS/2 2.x specific way of releasing one (or more) slices:

  xor     dx,dx
  mov     ax,woMilliSecs  ; Number of milliseconds in DX:AX, a
                          ; value of 0 means that the current
                          ; timeslice is released.
  hlt                     ; Call OS/2.
  db      35h,0CAh        ; Signature to differentiate between a
                          ; normal HLT-instruction and the call to
                          ; DosSleep().

Yes -- that is a "HALT CPU" instruction (are you reading this
Robert King?) -- since that is a protected instruction,  it generates a
processor fault;  an OS/2 exception hander sees the special "35,
ca" signature that follows and (rather than terminating the VDM)
interprets it as a DosSleep.


--- Maximus/2 2.01
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/99 3615/50 229/2 12/2442 711/409 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™.