Support Priority Boosting during Wait Satisfaction and Thread Abortion, and use it where necessary. Should provide a bit more responsiveness.

svn path=/trunk/; revision=14049
This commit is contained in:
Alex Ionescu 2005-03-14 06:44:31 +00:00
parent 3d801bebec
commit 8b97b835f2
9 changed files with 27 additions and 19 deletions

View file

@ -160,7 +160,11 @@ VOID inline FASTCALL KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header, ULO
VOID KeDumpStackFrames(PULONG Frame); VOID KeDumpStackFrames(PULONG Frame);
BOOLEAN KiTestAlert(VOID); BOOLEAN KiTestAlert(VOID);
VOID FASTCALL KiAbortWaitThread(struct _KTHREAD* Thread, NTSTATUS WaitStatus); VOID
FASTCALL
KiAbortWaitThread(PKTHREAD Thread,
NTSTATUS WaitStatus,
KPRIORITY Increment);
BOOLEAN STDCALL KiInsertTimer(PKTIMER Timer, LARGE_INTEGER DueTime); BOOLEAN STDCALL KiInsertTimer(PKTIMER Timer, LARGE_INTEGER DueTime);

View file

@ -276,7 +276,7 @@ KeInsertQueueApc(PKAPC Apc,
(Apc->NormalRoutine == NULL)) { (Apc->NormalRoutine == NULL)) {
DPRINT("Waking up Thread for Kernel-Mode APC Delivery \n"); DPRINT("Waking up Thread for Kernel-Mode APC Delivery \n");
KiAbortWaitThread(Thread, STATUS_KERNEL_APC); KiAbortWaitThread(Thread, STATUS_KERNEL_APC, PriorityBoost);
} }
} else if ((Thread->State == THREAD_STATE_BLOCKED) && } else if ((Thread->State == THREAD_STATE_BLOCKED) &&
@ -285,7 +285,7 @@ KeInsertQueueApc(PKAPC Apc,
DPRINT("Waking up Thread for User-Mode APC Delivery \n"); DPRINT("Waking up Thread for User-Mode APC Delivery \n");
Thread->ApcState.UserApcPending = TRUE; Thread->ApcState.UserApcPending = TRUE;
KiAbortWaitThread(Thread, STATUS_USER_APC); KiAbortWaitThread(Thread, STATUS_USER_APC, PriorityBoost);
} }
/* Return Sucess if we are here */ /* Return Sucess if we are here */

View file

@ -1,11 +1,12 @@
/* $Id$ /*
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/event.c * FILE: ntoskrnl/ke/event.c
* PURPOSE: Implements events * PURPOSE: Implements events
* *
* PROGRAMMERS: David Welch (welch@mcmail.com) * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* David Welch (welch@mcmail.com)
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -203,7 +204,7 @@ KeSetEvent(PKEVENT Event,
/* We can satisfy wait simply by waking the thread, since our signal state is 0 now */ /* We can satisfy wait simply by waking the thread, since our signal state is 0 now */
DPRINT("WaitAny or Sync Event, just unwait the thread\n"); DPRINT("WaitAny or Sync Event, just unwait the thread\n");
KiAbortWaitThread(WaitBlock->Thread, WaitBlock->WaitKey); KiAbortWaitThread(WaitBlock->Thread, WaitBlock->WaitKey, Increment);
} }
} }
@ -259,7 +260,7 @@ KeSetEventBoostPriority(IN PKEVENT Event,
/* Reset the Quantum and Unwait the Thread */ /* Reset the Quantum and Unwait the Thread */
WaitingThread->Quantum = WaitingThread->ApcState.Process->ThreadQuantum; WaitingThread->Quantum = WaitingThread->ApcState.Process->ThreadQuantum;
KiAbortWaitThread(WaitingThread, STATUS_SUCCESS); KiAbortWaitThread(WaitingThread, STATUS_SUCCESS, EVENT_INCREMENT);
} }
/* Release the Dispatcher Database Lock */ /* Release the Dispatcher Database Lock */

View file

@ -4,7 +4,7 @@
* FILE: ntoskrnl/ke/kthread.c * FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Microkernel thread support * PURPOSE: Microkernel thread support
* *
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Commented, reorganized some stuff, fixed/implemented some functions. * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* David Welch (welch@cwcom.net) * David Welch (welch@cwcom.net)
*/ */
@ -14,6 +14,7 @@
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
#define THREAD_ALERT_INCREMENT 2
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
ULONG ULONG
@ -36,7 +37,7 @@ KeAlertResumeThread(IN PKTHREAD Thread)
if (Thread->State == THREAD_STATE_BLOCKED && Thread->Alertable) { if (Thread->State == THREAD_STATE_BLOCKED && Thread->Alertable) {
DPRINT("Aborting Wait\n"); DPRINT("Aborting Wait\n");
KiAbortWaitThread(Thread, STATUS_ALERTED); KiAbortWaitThread(Thread, STATUS_ALERTED, THREAD_ALERT_INCREMENT);
} else { } else {
@ -89,7 +90,7 @@ KeAlertThread(PKTHREAD Thread,
Thread->Alertable) { Thread->Alertable) {
DPRINT("Aborting Wait\n"); DPRINT("Aborting Wait\n");
KiAbortWaitThread(Thread, STATUS_ALERTED); KiAbortWaitThread(Thread, STATUS_ALERTED, THREAD_ALERT_INCREMENT);
} else { } else {

View file

@ -1,11 +1,12 @@
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/queue.c * FILE: ntoskrnl/ke/queue.c
* PURPOSE: Implements kernel queues * PURPOSE: Implements kernel queues
* *
* PROGRAMMERS: Eric Kohl (ekohl@rz-online.de) * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Gunnar Dalsnes
* Eric Kohl (ekohl@rz-online.de)
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -409,7 +410,7 @@ KiWakeQueue(IN PKQUEUE Queue)
/* Unwait the Thread */ /* Unwait the Thread */
DPRINT("Unwaiting Thread\n"); DPRINT("Unwaiting Thread\n");
WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry); WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry);
KiAbortWaitThread(WaitBlock->Thread, (NTSTATUS)QueueEntry); KiAbortWaitThread(WaitBlock->Thread, (NTSTATUS)QueueEntry, IO_NO_INCREMENT);
} }
} }
} }

View file

@ -111,7 +111,7 @@ KeReleaseSemaphore(PKSEMAPHORE Semaphore,
if (InitialState == 0 && !IsListEmpty(&Semaphore->Header.WaitListHead)) { if (InitialState == 0 && !IsListEmpty(&Semaphore->Header.WaitListHead)) {
/* Wake the Semaphore */ /* Wake the Semaphore */
KiWaitTest(&Semaphore->Header, SEMAPHORE_INCREMENT); KiWaitTest(&Semaphore->Header, Increment);
} }
/* If the Wait is true, then return with a Wait and don't unlock the Dispatcher Database */ /* If the Wait is true, then return with a Wait and don't unlock the Dispatcher Database */

View file

@ -291,7 +291,7 @@ KiHandleExpiredTimer(PKTIMER Timer)
/* Set it as Signaled */ /* Set it as Signaled */
DPRINT("Setting Timer as Signaled\n"); DPRINT("Setting Timer as Signaled\n");
Timer->Header.SignalState = TRUE; Timer->Header.SignalState = TRUE;
KiWaitTest(&Timer->Header, 0); KiWaitTest(&Timer->Header, IO_NO_INCREMENT);
/* If the Timer is periodic, reinsert the timer with the new due time */ /* If the Timer is periodic, reinsert the timer with the new due time */
if (Timer->Period) { if (Timer->Period) {

View file

@ -702,7 +702,7 @@ KiWaitTest(PDISPATCHER_HEADER Object,
/* All waits satisfied, unwait the thread */ /* All waits satisfied, unwait the thread */
DPRINT("Unwaiting the Thread\n"); DPRINT("Unwaiting the Thread\n");
KiAbortWaitThread(CurrentWaitBlock->Thread, CurrentWaitBlock->WaitKey); KiAbortWaitThread(CurrentWaitBlock->Thread, CurrentWaitBlock->WaitKey, Increment);
SkipUnwait: SkipUnwait:
/* Next entry */ /* Next entry */
@ -716,7 +716,8 @@ SkipUnwait:
VOID VOID
FASTCALL FASTCALL
KiAbortWaitThread(PKTHREAD Thread, KiAbortWaitThread(PKTHREAD Thread,
NTSTATUS WaitStatus) NTSTATUS WaitStatus,
KPRIORITY Increment)
{ {
PKWAIT_BLOCK WaitBlock; PKWAIT_BLOCK WaitBlock;

View file

@ -297,7 +297,7 @@ PsTerminateOtherThread(PETHREAD Thread,
if (THREAD_STATE_BLOCKED == Thread->Tcb.State && UserMode == Thread->Tcb.WaitMode) if (THREAD_STATE_BLOCKED == Thread->Tcb.State && UserMode == Thread->Tcb.WaitMode)
{ {
DPRINT("Unblocking thread\n"); DPRINT("Unblocking thread\n");
KiAbortWaitThread((PKTHREAD)Thread, STATUS_THREAD_IS_TERMINATING); KiAbortWaitThread((PKTHREAD)Thread, STATUS_THREAD_IS_TERMINATING, IO_NO_INCREMENT);
} }
KeReleaseDispatcherDatabaseLock(OldIrql); KeReleaseDispatcherDatabaseLock(OldIrql);
} }