home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
desqview
/
dvmon13.arc
/
DVMON.C
next >
Wrap
C/C++ Source or Header
|
1988-06-20
|
6KB
|
206 lines
/* DVMON.C Turbo C 1.5 Source for DESQview 2.0 Performance Monitor */
/*
* Copyright 1988 Barry A. Burke. All rights, except those
* specifically granted herein are reserved by the author. The right
* to copy and distribute this material is granted without fee for
* any and all non-commercial use. This material specifically may
* not be distributed or sold for a fee nor incorporated in whole or
* in part into any other product that is distributed or sold for a
* fee without specific permission of the author. To obtain special
* permission or to report any difficulties with this material
* contact:
* Barry A. Burke
* Marketing Insights
* 35 Elizabeth Circle
* Framingham, MA 01701
*
* THIS MATERIAL IS DISTRIBUTED "as is" WITHOUT ANY EXPRESSED OR
* IMPLIED WARRANTY OR LIABILITY FOR DIRECT, INDIRECT OR
* CONSEQUENTIAL DAMAGES.
*
*
* Revision History:
* 1.0 May 13, 1988 BAB Initial version sent to Quarterdeck BBoard
* 1.1 May 16, 1988 BAB Removed DV Criticial stuff - fixes Bell
* problem (better, anyway).
* 1.2 June 17, 1988 RDB reduced CPU overhead by factor of 5, memory use
* by factor of 3
* 1.3 June 20, 1988 RDB some more performance tweaks
*/
#pragma inline
#include <time.h>
#include <bios.h>
#include <dos.h>
#include <stdlib.h>
/* TurboC System Stuff */
unsigned _stklen = 128; /* need smallest stack */
unsigned _heaplen = 1; /* smallest heap possbile */
void _setenvp(void){} /* dummy out _setenvp */
void _setargv(void){} /* dummy out _setargv */
void exit(int c) /* minimal EXIT() function */
{ _exit(c);}
/* Global Variables */
int IN_DV = 0;
#define INCRSECS 1 /* Number of seconds between */
/* Updates */
#define DvPause() _AX = 0x1000, geninterrupt(0x15)
#define LongTicks() biostime(0,0L)
#define bioschar(c) _AL = c ; _AH = 0x0E ; _BX = 0x0007 ; asm push bp ; asm int 10h ; asm pop bp
#define biosgoto(row,col) _DH = row ; _DL = col ; _AH= 0x02 ; _BH = 0 ; __int__(0x10)
/* Function Declarations */
static int near DvGetVersion(void)
{
asm mov CX,'DE' /* Invalid date */
asm mov DX,'SQ' /* accepted by DESQview */
asm mov AX,2B01H /* DOS Set Date/DESQ int */
asm int 21H
asm cmp AL,0FFH
asm je NO_DV
asm mov BX,AX /* returned version number */
asm mov IN_DV,1
asm jmp short DVGV_RET
NO_DV:
asm sub AX,AX
DVGV_RET:
}
void pascal put_int( int val, int len )
{
char number[8] ;
register int count = 0 ;
char pad = (len > 0) ? '0' : ' ' ;
do {
number[count++] = (val % 10) + '0' ;
val /= 10 ;
} while (val) ;
if (len < 0)
len = -len ;
while (count < len)
number[count++] = pad ;
while (--count >= 0)
{
_AL = number[count] ;
_AH = 0x0E ;
_BX = 0x0007 ;
asm push bp
asm int 10h
asm pop bp
}
}
void pascal bioswrite( register char *s )
{
while (*s)
{
_AL = *s++ ;
_AH = 0x0E ;
_BX = 0x0007 ;
asm push bp
asm int 10h
asm pop bp
}
}
void main()
{
long goaltime ;
register int counter, maxcount;
struct time tim ;
struct date dat ;
DvGetVersion(); /* Find out if we're in DV */
if ( !IN_DV )
{
bioswrite( "This is a DESQview program!" ) ;
exit(1);
}
bioswrite( "DVMON 1.3:\r\n Calibrating..." );/* Start calibration loop */
maxcount = 0;
goaltime = LongTicks() + 2 ; /* since we're the only one running, */
/* we don't need to wait very long to */
while ( LongTicks() < goaltime ) /* get to an even-tick boundary */
;
goaltime = LongTicks() + 18;
while ( LongTicks() < goaltime )
{
DvPause();
++maxcount;
}
maxcount = ( maxcount * INCRSECS );
_AH = 0x01 ; /* make cursor invisible */
_CH = 15 ;
_CL = 15 ;
__int__(0x10) ;
biosgoto(0,0) ;
getdate(&dat) ;
put_int( dat.da_mon, -2 ) ;
bioschar( '-' ) ;
put_int( dat.da_day, 2 ) ;
bioschar( '-' ) ;
put_int( dat.da_year - 1900, 2 ) ;
bioswrite(" \r\n" /* cover anything which might already be on the screen */
" % CPU unused" ) ;
while ( 1 )
{
counter = 0;
goaltime = LongTicks() + (INCRSECS*18L);
if ( goaltime > 1572000L ) /* Handle midnight wrap */
goaltime = 1572000L;
while ( LongTicks() < goaltime )
{
DvPause();
++counter;
}
gettime(&tim);
if (tim.ti_hour == 0 && tim.ti_min == 0)
{ /* at midnight, we need to update the date */
biosgoto(0,0) ;
getdate(&dat) ;
put_int( dat.da_mon, -2 ) ;
bioschar( '-' ) ;
put_int( dat.da_day, 2 ) ;
bioschar( '-' ) ;
put_int( dat.da_year - 1900, 2 ) ;
}
biosgoto(0,9) ;
put_int( tim.ti_hour, -2 ) ;
bioschar( ':' ) ;
put_int( tim.ti_min, 2 ) ;
bioschar( ':' ) ;
put_int( tim.ti_sec, 2 ) ;
biosgoto(1,0) ;
put_int( (int)(counter * 100L / maxcount), -3 ) ;
/* In order to avoid the appearance we are locked up if somebody tries to
* type in our window, then switch away, we flush the bios keyboard buffer
* once a second. This also prevent DESQview's warning bell from running
* until the next key pressed, tho I don't really know why.
*/
while ( bioskey( 1 ) ) /* Flush keyboard buffer */
bioskey( 0 );
}
}