diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index 7bf5801bd46..0069df63d02 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -32,9 +32,9 @@ #ifndef __ASM__ extern LARGE_INTEGER SystemBootTime; -extern ULONG KiKernelTime; -extern ULONG KiUserTime; -extern ULONG KiDpcTime; +extern volatile ULONG KiKernelTime; +extern volatile ULONG KiUserTime; +extern volatile ULONG KiDpcTime; #endif /* INTERNAL KERNEL FUNCTIONS ************************************************/ @@ -136,6 +136,9 @@ KeBugCheckWithTf(ULONG BugCheckCode, VOID KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG ExceptionNr, ULONG cr2); +VOID +KiUpdateProcessThreadTime(VOID); + #endif /* not __ASM__ */ #define MAXIMUM_PROCESSORS 32 diff --git a/reactos/ntoskrnl/ke/i386/irq.c b/reactos/ntoskrnl/ke/i386/irq.c index adcf14de105..da2757a88d8 100644 --- a/reactos/ntoskrnl/ke/i386/irq.c +++ b/reactos/ntoskrnl/ke/i386/irq.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: irq.c,v 1.41 2004/03/09 21:49:53 dwelch Exp $ +/* $Id: irq.c,v 1.42 2004/04/14 23:32:38 jimtabor Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/irq.c @@ -521,6 +521,11 @@ KiInterruptDispatch (ULONG irq, PKIRQ_TRAPFRAME Trapframe) HalEndSystemInterrupt (old_level, 0); + if (old_level==PASSIVE_LEVEL) + { + KiUpdateProcessThreadTime(); + } + if (old_level==PASSIVE_LEVEL && Trapframe->Cs != KERNEL_CS) { CurrentThread = KeGetCurrentThread(); diff --git a/reactos/ntoskrnl/ke/timer.c b/reactos/ntoskrnl/ke/timer.c index ba0dbede233..52793d68fca 100644 --- a/reactos/ntoskrnl/ke/timer.c +++ b/reactos/ntoskrnl/ke/timer.c @@ -1,4 +1,4 @@ -/* $Id: timer.c,v 1.69 2004/04/14 17:14:45 jimtabor Exp $ +/* $Id: timer.c,v 1.70 2004/04/14 23:32:37 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -38,9 +38,9 @@ LARGE_INTEGER SystemBootTime = (LARGE_INTEGER)0LL; LARGE_INTEGER SystemBootTime = { 0 }; #endif -ULONG KiKernelTime; -ULONG KiUserTime; -ULONG KiDpcTime; +volatile ULONG KiKernelTime; +volatile ULONG KiUserTime; +volatile ULONG KiDpcTime; /* * Number of timer interrupts since initialisation @@ -600,10 +600,7 @@ KiUpdateSystemTime(KIRQL oldIrql, */ { LARGE_INTEGER Time; -/* - PKTHREAD CurrentThread; - PKPROCESS CurrentProcess; - */ + assert(KeGetCurrentIrql() == PROFILE_LEVEL); KiRawTicks++; @@ -634,24 +631,6 @@ KiUpdateSystemTime(KIRQL oldIrql, SharedUserData->SystemTime.LowPart = Time.u.LowPart; SharedUserData->SystemTime.High1Part = Time.u.HighPart; -/* - CurrentThread = KeGetCurrentThread(); - CurrentProcess = KeGetCurrentProcess(); - - if (CurrentThread->PreviousMode == UserMode) - { - ++CurrentThread->UserTime; - ++CurrentProcess->UserTime; - ++KiUserTime; - } - if (CurrentThread->PreviousMode == KernelMode) - { - ++CurrentProcess->KernelTime; - ++CurrentThread->KernelTime; - ++KiKernelTime; - } - */ - KiReleaseSpinLock(&TimerValueLock); /* @@ -694,3 +673,31 @@ KeInitializeTimerImpl(VOID) TimerInitDone = TRUE; DPRINT("Finished KeInitializeTimerImpl()\n"); } + + +VOID +KiUpdateProcessThreadTime(VOID) +{ + PKTHREAD CurrentThread; + PKPROCESS CurrentProcess; + + assert(KeGetCurrentIrql() == PASSIVE_LEVEL); + + CurrentThread = KeGetCurrentThread(); + CurrentProcess = KeGetCurrentProcess(); + + DPRINT("KiKernelTime %u, KiUserTime %u \n", KiKernelTime, KiUserTime); + + if (CurrentThread->PreviousMode == UserMode) + { + ++CurrentThread->UserTime; + ++CurrentProcess->UserTime; + ++KiUserTime; + } + if (CurrentThread->PreviousMode == KernelMode) + { + ++CurrentProcess->KernelTime; + ++CurrentThread->KernelTime; + ++KiKernelTime; + } +}