Path: utzoo!attcan!uunet!nih-csl!helix.nih.gov From: bert@helix.nih.gov (Bert Tyler) Newsgroups: comp.windows.ms Subject: Re: Non-Win App surrendering its time slice Message-ID: <546@nih-csl.nih.gov> Date: 8 Oct 90 14:07:43 GMT Sender: news@nih-csl.nih.gov Organization: National Institutes of Health, Bethesda Lines: 37 > 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