Board index » delphi » BP7.01 : Reduce processor load under OS/2

BP7.01 : Reduce processor load under OS/2

Hi!
Users wanting to use one of my programs under OS/2 recently
told me that it was using up processor resources to 100%. I
tried it and - sure enough - pulse showed 100% load when executing
the program under Warp in a DOS box.
Are there tried and trusted methods of
a) detecting that the program is running under OS/2, and
b) giving time slices to the OS when in idle mode?

The program is a BBS program and need to continually poll the
serial line. OK, I know polling isn't great, but I interface to
the FOSSIL driver and have no interrupt handling routines.

I know that there are DesqView Interrupts which allow the program
to release unused process time. Surely, such a thing must exist in Warp
as well?

Any hints on this would be greatly apreciated.

Bye,
        Daniel

 

Re:BP7.01 : Reduce processor load under OS/2


Quote
In article <3s9260$...@mars.darmstadt.gmd.de>, Daniel Tietze <tie...@darmstadt.gmd.de> writes:

|> Hi!
|> Users wanting to use one of my programs under OS/2 recently
|> told me that it was using up processor resources to 100%. I
|> tried it and - sure enough - pulse showed 100% load when executing
|> the program under Warp in a DOS box.
|> Are there tried and trusted methods of
|> a) detecting that the program is running under OS/2, and
|> b) giving time slices to the OS when in idle mode?
|>
|> The program is a BBS program and need to continually poll the
|> serial line. OK, I know polling isn't great, but I interface to
|> the FOSSIL driver and have no interrupt handling routines.

I think that most multitaskers hook INT28 (description follows).
Therefore, you should try to call it after each polling of the serial
line, you can do a

  inline($CD,$28)

to invoke this interrupt. Therefore, you do not have to detect OS/2 for
it to work.  

I should point out that I used it in one of my programs, but that I
cannot swear that it does something since I work on a 286 :-( Try it and
tell me if it works.

Hope this helps.

Jean-Marc.

From Ralf Brown's interrupt list:

INT 28 C - DOS 2+ - DOS IDLE INTERRUPT
        SS:SP = top of MS-DOS stack for I/O functions
Return: all registers preserved
Desc:   This interrupt is invoked each time one of the DOS character input
          functions loops while waiting for input.  Since a DOS call is in
          progress even though DOS is actually idle during such input waits,
          hooking this function is necessary to allow a TSR to perform DOS
          calls while the foreground program is waiting for user input.  The
          INT 28h handler may invoke any INT 21h function except functions
          00h through 0Ch.
Notes:  under DOS 2.x, the critical error flag (the byte immediately after the
          InDOS flag) must be set in order to call DOS functions 50h/51h from
          the INT 28h handler without destroying the DOS stacks.
        calls to INT 21/AH=3Fh,40h from within an INT 28 handler may not use a
          handle which refers to CON
        at the time of the call, the InDOS flag (see INT 21/AH=34h) is normally
          set to 01h; if larger, DOS is truly busy and should not be reentered
        the default handler is an IRET instruction
        supported in OS/2 compatibility box
        the _MS-DOS_Programmer's_Reference_ for DOS 5.0 incorrectly documents
          this interrupt as superseded
SeeAlso: INT 21/AH=34h,INT 2A/AH=84h,INT 2F/AX=1680h

--
-------------------------------------------------
Jean-Marc Lasgouttes, Projet MEVAL, INRIA, France
e-mail : jean-marc.lasgout...@inria.fr

Re:BP7.01 : Reduce processor load under OS/2


Quote
Daniel Tietze <tie...@darmstadt.gmd.de> writes:
>Hi!
>Users wanting to use one of my programs under OS/2 recently
>told me that it was using up processor resources to 100%. I
>tried it and - sure enough - pulse showed 100% load when executing
>the program under Warp in a DOS box.
>Are there tried and trusted methods of
>a) detecting that the program is running under OS/2, and
>b) giving time slices to the OS when in idle mode?
>The program is a BBS program and need to continually poll the
>serial line. OK, I know polling isn't great, but I interface to
>the FOSSIL driver and have no interrupt handling routines.
>I know that there are DesqView Interrupts which allow the program
>to release unused process time. Surely, such a thing must exist in Warp
>as well?
>Any hints on this would be greatly apreciated.
>Bye,
>    Daniel

There is a generic idle interupt beginning with the 286 which tells the OS
that its services are not needed for a few microseconds. I used the following
procedure to reduce system load under OS/2. You have to be somewhat carefull
if you want to avoid performance impairment of your program if it gets too
little attention. I tried it in the keyboard read handling. There it was
unacceptable. But in the main loop of my HFM file manager program (read keyboard and
mouse, update watch and screensaver and some other assorted tasks) it does
not have ill effects. The only draw back is that it does not work well with
Win95 in its default configuration.

var register:registers;
procedure idle;
begin
register.ah := 134;
register.cx := 0;
register.dx := 1000;
intr (21,register);
end;

Andreas
--
*  Andreas Helke,  Institut fuer molekulare Genetik, Universitaet Heidelberg
**                        Im Neuenheimer Feld 230, 69122 Heidelberg, Germany
***                                 WWW: http://orion.mgen.uni-heidelberg.de
**** ftp://orion.mgen.uni-heidelberg.de - filemanager and Unix tools for DOS

Re:BP7.01 : Reduce processor load under OS/2


Quote
Daniel Tietze (tie...@darmstadt.gmd.de) wrote:

: Users wanting to use one of my programs under OS/2 recently
: told me that it was using up processor resources to 100%. I
: tried it and - sure enough - pulse showed 100% load when executing
: the program under Warp in a DOS box.
: Are there tried and trusted methods of
: a) detecting that the program is running under OS/2, and
: b) giving time slices to the OS when in idle mode?

: The program is a BBS program and need to continually poll the
: serial line. OK, I know polling isn't great, but I interface to
: the FOSSIL driver and have no interrupt handling routines.

Let me tell you about my experiences with serial communication in the
DOS box of OS/2. First thing: when the box is idle it will show with
most monitoring programs a CPU-load of 100%. The moment you start some-
thing, this drops. No harm in that, it is caused by some DOS needed
polling, but because this happens with low-priority it doesn't give a
performance hit.

Second is RS232 access. I used self-made interrupt driven routines
(see ftp://garbo.uwasa.fi/pc/turbopas/comtty30.zip or
     ftp://oak.oakland.edu/pub/turbopas/comtty30.zip) but discovered
that when you implement for example a terminal emulator with a loop
that constantly checks both keyboard and serial port, performance
improves drastically by putting somewhere in the loop a very short
call to "Delay()". Probably this call enables the process scheduler
to take over.

Willem

W    i    l    l    e    m        v    a    n        S    c    h    a    i    k
-------------------------------------------------------------------------------
Gintic - Singapore                                     gwil...@ntuvax.ntu.ac.sg

Re:BP7.01 : Reduce processor load under OS/2


Hi Daniel and All,

In <3s9260$...@mars.darmstadt.gmd.de>, Daniel Tietze

Quote
 <tie...@darmstadt.gmd.de> writes:
>Hi!
>Users wanting to use one of my programs under OS/2 recently
>told me that it was using up processor resources to 100%. I
>tried it and - sure enough - pulse showed 100% load when executing
>the program under Warp in a DOS box.
>Are there tried and trusted methods of
>a) detecting that the program is running under OS/2, and
>b) giving time slices to the OS when in idle mode?

   Yes, and Yes.

   I had a similar problem running a compiled BASIC program under OS/2.  It
should be very simple to port to Pascal.  I assembled a zip file
(qbslice.zip) and posted it to ftp-os2.nmsu.edu in /dos.

   Here are the relevant BASIC routines:

FUNCTION DOSVersion! STATIC

' This routine determines the OS version that the program is runing under.
' Needed, e.g., in case we are running graphics in a window in OS/2 (many
' graphics modes aren't virtualized in a window if runing WPS in high
' resolution)

DIM reg AS RegType
reg.ax = &H3000
Interrupt &H21, reg, reg
major% = reg.ax MOD 256    
minor% = reg.ax \ 256      
DOSVersion! = major% + minor% / 100   ' 20.3 for OS/2 Warp version 3
END FUNCTION

SUB SliceMe

' This subroutine gives up a time slice to Warp.
' It is documented in IBM's OS/2 Virtual Device Driver manual, part
' of the OS/2 Technical Library, and in Ralf Brown's Interrupt List.

DIM reg AS RegType
reg.ax = &H1680
Interrupt &H2F, reg, reg ' Give up the time slice to OS/2
END SUB

   More information is available in the .zip file.

Quote
>Any hints on this would be greatly apreciated.

   I know it's not Pascal, but it should give the necessary information for
you to solve your problem.  I hope this helps.

Cheers,
Scott.
------
D. Scott Katzer - NRL Code 6856 - Washington, D.C. 20375-5347 USA
                My time, my computer, my opinions.
Naval Research Lab WWW Home Page:  http://www.nrl.navy.mil

Other Threads