From 129c75c64da4c685b9dfaa656964c43c494c5c19 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 31 Oct 2004 21:22:06 +0000 Subject: [PATCH] - Call KiDispatchInterrupt only if DPC software interrupt was requested. (TODO: The same should be done for APCs.) - Request DPC/APC software interrupts where we should. - Fix condition in KeUpdateRunTime to allow switching thread early in the boot. - Set default thread quantum for system process. svn path=/trunk/; revision=11514 --- reactos/hal/halx86/irql.c | 8 ++++++-- reactos/ntoskrnl/ke/apc.c | 2 ++ reactos/ntoskrnl/ke/dpc.c | 3 ++- reactos/ntoskrnl/ke/timer.c | 16 +++++----------- reactos/ntoskrnl/ps/process.c | 3 ++- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/reactos/hal/halx86/irql.c b/reactos/hal/halx86/irql.c index 14279465791..b37c41d6e19 100644 --- a/reactos/hal/halx86/irql.c +++ b/reactos/hal/halx86/irql.c @@ -1,4 +1,4 @@ -/* $Id: irql.c,v 1.17 2004/10/23 23:43:23 ion Exp $ +/* $Id: irql.c,v 1.18 2004/10/31 21:22:06 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -176,7 +176,11 @@ HalpLowerIrql(KIRQL NewIrql) return; } KeGetCurrentKPCR()->Irql = DISPATCH_LEVEL; - KiDispatchInterrupt(); + if (DpcRequested) + { + DpcRequested = FALSE; + KiDispatchInterrupt(); + } KeGetCurrentKPCR()->Irql = APC_LEVEL; if (NewIrql == APC_LEVEL) { diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index 50627e6a94e..feecbb63d1f 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -370,6 +370,7 @@ KeInsertQueueApc (PKAPC Apc, if (Apc->ApcMode == KernelMode && TargetThread == KeGetCurrentThread() && Apc->NormalRoutine == NULL) { + HalRequestSoftwareInterrupt(APC_LEVEL); KeLowerIrql(oldlvl); return TRUE; } @@ -424,6 +425,7 @@ KeInsertQueueApc (PKAPC Apc, KeRemoveAllWaitsThread(CONTAINING_RECORD(TargetThread, ETHREAD, Tcb), STATUS_USER_APC, TRUE); } + HalRequestSoftwareInterrupt(APC_LEVEL); KeLowerIrql(oldlvl); return TRUE; } diff --git a/reactos/ntoskrnl/ke/dpc.c b/reactos/ntoskrnl/ke/dpc.c index 920f62e9b01..8d11fc8bec3 100644 --- a/reactos/ntoskrnl/ke/dpc.c +++ b/reactos/ntoskrnl/ke/dpc.c @@ -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.44 2004/10/31 17:02:31 hbirr Exp $ +/* $Id: dpc.c,v 1.45 2004/10/31 21:22:06 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -304,6 +304,7 @@ KeInsertQueueDpc (PKDPC Dpc, { Pcr->PrcbData.MaximumDpcQueueDepth = Pcr->PrcbData.DpcData[0].DpcQueueDepth; } + HalRequestSoftwareInterrupt(DISPATCH_LEVEL); KiReleaseSpinLock(&Pcr->PrcbData.DpcData[0].DpcLock); KeLowerIrql(oldlvl); DPRINT("DpcQueueHead.Flink %x\n", Pcr->PrcbData.DpcData[0].DpcListHead.Flink); diff --git a/reactos/ntoskrnl/ke/timer.c b/reactos/ntoskrnl/ke/timer.c index a57cb3aa78f..d80073b8b76 100644 --- a/reactos/ntoskrnl/ke/timer.c +++ b/reactos/ntoskrnl/ke/timer.c @@ -1,4 +1,4 @@ -/* $Id: timer.c,v 1.86 2004/10/31 15:24:06 hbirr Exp $ +/* $Id: timer.c,v 1.87 2004/10/31 21:22:06 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -698,19 +698,13 @@ KeUpdateRunTime( Pcr = KeGetCurrentKPCR(); - /* - * Make sure no counting can take place until Processes and Threads are - * running! - */ - if ((PsInitialSystemProcess == NULL) || (Pcr->PrcbData.IdleThread == NULL) || - (KiTimerSystemAuditing == 0)) - { - return; - } + /* Make sure we don't go further if we're in early boot phase. */ + if (Pcr == NULL || Pcr->PrcbData.CurrentThread == NULL) + return; DPRINT("KernelTime %u, UserTime %u \n", Pcr->PrcbData.KernelTime, Pcr->PrcbData.UserTime); - CurrentThread = /* Pcr->PcrbData.CurrentThread */ KeGetCurrentThread(); + CurrentThread = Pcr->PrcbData.CurrentThread; CurrentProcess = CurrentThread->ApcState.Process; /* diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index ac0ccb3740d..c2e6b8ed53f 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.147 2004/10/30 23:48:57 navaraf Exp $ +/* $Id: process.c,v 1.148 2004/10/31 21:22:06 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -293,6 +293,7 @@ PsInitProcessManagment(VOID) PsInitialSystemProcess->Pcb.LdtDescriptor[0] = 0; PsInitialSystemProcess->Pcb.LdtDescriptor[1] = 0; PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL; + PsInitialSystemProcess->Pcb.ThreadQuantum = 6; InitializeListHead(&PsInitialSystemProcess->Pcb.ThreadListHead); KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.DispatcherHeader, InternalProcessType,