Mail Archives: djgpp/1997/11/26/15:32:33
From: | michael DOT mauch AT gmx DOT de (Michael Mauch)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Intermittent Run-Time of DJGPP App under Win95
|
Date: | Wed, 26 Nov 1997 12:13:31 +0100
|
Organization: | Gerhard-Mercator-Universitaet -GH- Duisburg
|
Lines: | 119
|
Message-ID: | <348488fe.61835728@news.uni-duisburg.de>
|
References: | <m0xaFyg-000S23C AT inti DOT gov DOT ar>
|
NNTP-Posting-Host: | ppp85.uni-duisburg.de
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
On Tue, 25 Nov 1997 11:07:41 GMT, "Salvador Eduardo Tropea (SET)"
<salvador AT inti DOT edu DOT ar> wrote:
> George Foot <mert0407 AT sable DOT ox DOT ac DOT uk> wrote:
> >
> > Win95's Virtual Timer Device VxD provides three functions; in
> > particular, one of them (0x0101) returns the time in milliseconds that
> > Windows has been active, and another (0x0102) returns the time in
> > milliseconds that the current session has been actively executed (I
> > forget the exact wording -- it means, how many milliseconds of the
> > processor's time have been spent on this DOS box). I believe you can
> > use a combination of the two to find out what percentage of CPU time
> > Windows is giving your application. Is this the information you were
> > seeking?
> Don't know. I think it can help to make the program to meassure the problem.
I think it should be possible.
Regards...
Michael
******* wintimer.c: ********
#include <string.h>
#include <dpmi.h>
#include <libc/bss.h>
#include "wintimer.h"
static int wintimer_bss = -1;
static unsigned long VTDcall(int func_num)
{
static struct
{
unsigned short lo,hi;
} VTD; /* address of the Virtual Timer Device API entry point */
__dpmi_regs regs;
if (wintimer_bss != __bss_count)
{
memset(®s,0,sizeof(regs));
regs.x.ax = 0x1684;
regs.x.bx = 0x0005;
regs.x.di = 0;
regs.x.es = 0;
if(__dpmi_simulate_real_mode_interrupt(0x2F,®s))
return 0; /* error: VTD API not available */
VTD.lo = regs.x.di;
VTD.hi = regs.x.es;
if(!(VTD.lo | VTD.hi))
return 0; /* error: VTD API not available */
wintimer_bss = __bss_count;
}
memset(®s,0,sizeof(regs));
regs.x.ax = func_num;
regs.x.cs = VTD.hi;
regs.x.ip = VTD.lo;
if(__dpmi_simulate_real_mode_procedure_retf(®s))
return 0; /* error: VTD API call failed */
return regs.d.eax;
}
unsigned long WinTimerWindowsRunning(void)
{
return VTDcall(0x101);
}
unsigned long WinTimerVirtualMachineRunning(void)
{
return VTDcall(0x102);
}
#ifdef TEST
#include <stdio.h>
int main()
{
unsigned long t1 = WinTimerWindowsRunning(),
t2 = WinTimerVirtualMachineRunning();
printf("Windows has been running for %lu milliseconds.\n", t1);
printf("This virtual machine has been running for %lu
milliseconds.\n", t2);
return 0;
}
#endif
******* wintimer.h: ********
#ifndef WINTIMER_H
#define WINTIMER_H
#ifdef __cplusplus
extern "C"
{
#endif
unsigned long WinTimerRunning(void);
unsigned long WinTimerVirtualMachineRunning(void);
#ifdef __cplusplus
}
#endif
#endif
- Raw text -