New Process & Thread time locking and experimental DPC accounting support.

svn path=/trunk/; revision=10315
This commit is contained in:
James Tabor 2004-07-29 23:28:48 +00:00
parent a769548161
commit acb7361211
3 changed files with 38 additions and 23 deletions

View file

@ -29,14 +29,6 @@
#include "arch/ke.h"
#ifndef __ASM__
extern LARGE_INTEGER SystemBootTime;
extern volatile ULONG KiKernelTime;
extern volatile ULONG KiUserTime;
extern volatile ULONG KiDpcTime;
#endif
/* INTERNAL KERNEL FUNCTIONS ************************************************/
#ifdef __USE_W32API
@ -106,6 +98,12 @@ KiDeliverNormalApc(VOID);
BOOLEAN STDCALL KeRemoveQueueApc (PKAPC Apc);
PLIST_ENTRY STDCALL KeRundownQueue(IN PKQUEUE Queue);
extern LARGE_INTEGER SystemBootTime;
extern volatile ULONGLONG KiKernelTime;
extern volatile ULONGLONG KiUserTime;
extern volatile ULONGLONG KiDpcTime;
/* INITIALIZATION FUNCTIONS *************************************************/
VOID KeInitExceptions(VOID);

View file

@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dpc.c,v 1.31 2004/06/23 22:31:51 ion Exp $
/* $Id: dpc.c,v 1.32 2004/07/29 23:28:31 jimtabor Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -42,12 +42,16 @@
#define NDEBUG
#include <internal/debug.h>
extern volatile ULONGLONG KeTickCount;
/* TYPES *******************************************************************/
/* GLOBALS ******************************************************************/
static LIST_ENTRY DpcQueueHead; /* Head of the list of pending DPCs */
static KSPIN_LOCK DpcQueueLock; /* Lock for the above list */
static ULONGLONG DpcTimeInside = 0;
/*
* Number of pending DPCs. This is inspected by
* the idle thread to determine if the queue needs to
@ -55,6 +59,11 @@ static KSPIN_LOCK DpcQueueLock; /* Lock for the above list */
*/
ULONG DpcQueueSize = 0;
/*
* Number of DPC's Processed.
*/
ULONG DpcCount = 0;
/* FUNCTIONS ****************************************************************/
/*
@ -102,6 +111,9 @@ KiDispatchInterrupt(VOID)
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
KiAcquireSpinLock(&DpcQueueLock);
DpcTimeInside = KeTickCount;
DpcCount = DpcCount + DpcQueueSize;
while (!IsListEmpty(&DpcQueueHead))
{
current_entry = RemoveHeadList(&DpcQueueHead);
@ -120,6 +132,8 @@ KiDispatchInterrupt(VOID)
KeRaiseIrql(HIGH_LEVEL, &oldlvl);
KiAcquireSpinLock(&DpcQueueLock);
}
KiDpcTime += (KeTickCount - DpcTimeInside);
KiReleaseSpinLock(&DpcQueueLock);
KeLowerIrql(oldlvl);
}

View file

@ -1,4 +1,4 @@
/* $Id: timer.c,v 1.74 2004/06/23 22:31:51 ion Exp $
/* $Id: timer.c,v 1.75 2004/07/29 23:28:31 jimtabor Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -27,6 +27,7 @@
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS ****************************************************************/
/*
@ -39,9 +40,9 @@ LARGE_INTEGER SystemBootTime = { 0 };
#endif
CHAR KiTimerSystemAuditing = 0;
volatile ULONG KiKernelTime;
volatile ULONG KiUserTime;
volatile ULONG KiDpcTime;
volatile ULONGLONG KiKernelTime;
volatile ULONGLONG KiUserTime;
volatile ULONGLONG KiDpcTime;
/*
* Number of timer interrupts since initialisation
@ -73,7 +74,6 @@ static KDPC ExpireTimerDpc;
extern ULONG PiNrRunnableThreads;
extern HANDLE PsIdleThreadHandle;
#define MICROSECONDS_PER_TICK (10000)
#define TICKS_TO_CALIBRATE (1)
#define CALIBRATE_PERIOD (MICROSECONDS_PER_TICK * TICKS_TO_CALIBRATE)
@ -644,7 +644,6 @@ KiUpdateSystemTime(KIRQL oldIrql,
*/
KeTickCount++;
SharedUserData->TickCountLow++;
KiAcquireSpinLock(&TimerValueLock);
Time.u.LowPart = SharedUserData->InterruptTime.LowPart;
@ -717,8 +716,8 @@ KiUpdateProcessThreadTime(VOID)
* Make sure no counting can take place until Processes and Threads are
* running!
*/
if ((PsInitialSystemProcess == NULL) ||
(PsIdleThreadHandle == NULL) || (KiTimerSystemAuditing == 0))
if ((PsInitialSystemProcess == NULL) || (PsIdleThreadHandle == NULL) ||
(KiTimerSystemAuditing == 0))
{
return;
}
@ -728,18 +727,22 @@ KiUpdateProcessThreadTime(VOID)
DPRINT("KiKernelTime %u, KiUserTime %u \n", KiKernelTime, KiUserTime);
/* Over kill with locks. */
KiAcquireSpinLock(&TimeLock);
if (CurrentThread->PreviousMode == UserMode)
{
++CurrentThread->UserTime;
++CurrentProcess->UserTime;
/* Lock the process & thread time. This should lock everything
* all the way down to the process & thread stuct.
*/
InterlockedIncrement((LONG *)&CurrentProcess->UserTime);
InterlockedIncrement((LONG *)&CurrentThread->UserTime);
++KiUserTime;
}
if (CurrentThread->PreviousMode == KernelMode)
{
++CurrentProcess->KernelTime;
++CurrentThread->KernelTime;
InterlockedIncrement((LONG *)&CurrentProcess->KernelTime);
InterlockedIncrement((LONG *)&CurrentThread->KernelTime);
++KiKernelTime;
}
@ -777,8 +780,8 @@ KeUpdateRunTime(
STDCALL
VOID
KeUpdateSystemTime(
IN PKTRAP_FRAME TrapFrame,
IN ULONG Increment
IN PKTRAP_FRAME TrapFrame,
IN ULONG Increment
)
{
UNIMPLEMENTED;