[comp.windows.ms] Non-Win App surrendering its time slice

bert@helix.nih.gov (Bert Tyler) (10/08/90)

> I have a program (UUPC) which makes a lousy application to run an
> Windows DOS window because it has an idle spin loop which soaks up
> a lot more CPU than it needs to.  
> 
> Is there a way for a non-Windows (Turbo C) application to gracefully
> surrender it's time slice?
>
> Likewise, is there a way for a non-Windows application to notify Windows
> that the application is entering a critical path and doesn't want to
> lose its time slice?
 
Drew, there is indeed a way for a DOS program to detect whether or not
it is running under Windows, and to both give up its time slice when idle
and grab the CPU during critical periods.  Sending this response through
the net because it is probably useful to a lot of people.  This info came
off the Interlink BBS network:
 
------------------- snip snip -------------------------------
 
KW>(And while were at it, folks, is there an easy way for a non-
KW>Windows app to tell it's running under Windows?)
Use this first to see if the rest are OK
                 MOV AX,1600h   ; Check for win386/win3.0 present
                 INT 2Fh
Return AL = 0 -> No Windows, AL = 80 -> No WIn386 mode
       AL = 1 or AL = FFh -> Win386 2.xx running
  else AL = Major version (3), AH = Minor version
--------------- Release time slice
                 MOV AX,352Fh   ; **** Release time slice
                 INT 2Fh        ; Let someone else run
Return code is AL = 80H -> service not installed, AL = 0 -> all OK
--------------- Enter critical section (disable task switch)
                 MOV AX,1681H   ; Don't tread on me!
                 INT 2Fh
--------------- End critical section (Permit task switching)
                 MOV AX,1682h
                 INT 2Fh

jls@hsv3.UUCP (James Seidman) (10/09/90)

In article <546@nih-csl.nih.gov> bert@helix.nih.gov (Bert Tyler) writes:
>--------------- Release time slice
>                 MOV AX,352Fh   ; **** Release time slice
>                 INT 2Fh        ; Let someone else run

Just to clarify, does this mean to simply terminate *this* particular
time slice, so that this call has to be made in a loop?  Also, how does
Windows do its "detect Idle time?"
-- 
Jim Seidman (Drax), the accidental engineer.
"There's a certain freedom to being completely screwed." - The Freshman
UUCP: ames!vsi1!headland!jls
ARPA: headland.UUCP!jls@ames.nasa.arc.gov