- MmDeleteKernelStack should take StackBase as the first parameter, not StackLimit (thus actually the need for the 2nd parameter - large stack size flag). Fix it, and fix callers.

- Make KiSwitchKernelStack return the stack base instead of the stack limit, as part of the above change.
- Don't increment priority when waking the thread in KeThawAllThreads.
- Fix new thread priority calculation in KiDeferredReadyThread.
- Fix double-semicolon typo in thrdini.c

svn path=/trunk/; revision=36157
This commit is contained in:
Aleksey Bragin 2008-09-12 11:13:15 +00:00
parent dd12a25642
commit bc125c3314
6 changed files with 17 additions and 12 deletions

View file

@ -217,7 +217,7 @@ Ke386InitThreadWithContext(IN PKTHREAD Thread,
/* And set up the Context Switch Frame */
CtxSwitchFrame->RetAddr = KiThreadStartup;
CtxSwitchFrame->ApcBypassDisable = TRUE;
CtxSwitchFrame->ExceptionList = EXCEPTION_CHAIN_END;;
CtxSwitchFrame->ExceptionList = EXCEPTION_CHAIN_END;
/* Save back the new value of the kernel stack. */
Thread->KernelStack = (PVOID)CtxSwitchFrame;

View file

@ -420,7 +420,7 @@ NoStack:
* @param StackLimit
* Pointer to the new Stack Limit of the thread.
*
* @return The previous Stack Limit of the thread.
* @return The previous Stack Base of the thread.
*
* @remark This routine should typically only be used when converting from a
* non-GUI to a GUI Thread. The caller is responsible for freeing the
@ -470,7 +470,7 @@ _KeSwitchKernelStack@8:
pop edi
/* Save old stack base and get new limit/base */
mov eax, [edx+KTHREAD_STACK_LIMIT]
mov eax, [edx+KTHREAD_STACK_BASE]
mov ecx, [esp+12]
mov esi, [esp+16]

View file

@ -99,7 +99,7 @@ KeSetDisableBoostThread(IN OUT PKTHREAD Thread,
ASSERT_THREAD(Thread);
/* Check if we're enabling or disabling */
if (Disable != FALSE)
if (Disable)
{
/* Set the bit */
return InterlockedBitTestAndSet(&Thread->ThreadFlags, 1);
@ -652,7 +652,7 @@ KeThawAllThreads(VOID)
/* Signal the suspend semaphore and wake it */
Current->SuspendSemaphore.Header.SignalState++;
KiWaitTest(&Current->SuspendSemaphore, 1);
KiWaitTest(&Current->SuspendSemaphore, 0);
/* Unlock the dispatcher */
KiReleaseDispatcherLockFromDpcLevel();
@ -833,7 +833,7 @@ KeInitThread(IN OUT PKTHREAD Thread,
if (AllocatedStack)
{
/* Delete the stack */
MmDeleteKernelStack((PVOID)Thread->StackLimit, FALSE);
MmDeleteKernelStack((PVOID)Thread->StackBase, FALSE);
Thread->InitialStack = NULL;
}
}
@ -875,7 +875,7 @@ NTAPI
KeUninitThread(IN PKTHREAD Thread)
{
/* Delete the stack */
MmDeleteKernelStack((PVOID)Thread->StackLimit, FALSE);
MmDeleteKernelStack((PVOID)Thread->StackBase, FALSE);
Thread->InitialStack = NULL;
}
@ -1157,6 +1157,9 @@ KeSetBasePriorityThread(IN PKTHREAD Thread,
if (Thread->Saturation) OldIncrement = (HIGH_PRIORITY + 1) / 2 *
Thread->Saturation;
/* Reset the saturation value */
Thread->Saturation = 0;
/* Now check if saturation is being used for the new value */
if (abs(Increment) >= ((HIGH_PRIORITY + 1) / 2))
{

View file

@ -55,7 +55,7 @@ KiDeferredReadyThread(IN PKTHREAD Thread)
{
/* Calculate the new priority based on the adjust increment */
OldPriority = min(Thread->AdjustIncrement + 1,
LOW_REALTIME_PRIORITY - 1);
LOW_REALTIME_PRIORITY - 3);
/* Make sure we're not decreasing outside of the priority range */
ASSERT((Thread->PriorityDecrement >= 0) &&

View file

@ -140,15 +140,17 @@ MiFreeStackPage(PVOID Context,
VOID
STDCALL
MmDeleteKernelStack(PVOID Stack,
MmDeleteKernelStack(PVOID StackBase,
BOOLEAN GuiStack)
{
ULONG StackSize = GuiStack ? KERNEL_LARGE_STACK_SIZE : KERNEL_STACK_SIZE;
/* Lock the Address Space */
MmLockAddressSpace(MmGetKernelAddressSpace());
/* Delete the Stack */
MmFreeMemoryAreaByPtr(MmGetKernelAddressSpace(),
Stack,
(PVOID)((ULONG_PTR)StackBase - StackSize),
MiFreeStackPage,
NULL);

View file

@ -188,7 +188,7 @@ PspReapRoutine(IN PVOID Context)
Thread = CONTAINING_RECORD(NextEntry, ETHREAD, ReaperLink);
/* Delete this entry's kernel stack */
MmDeleteKernelStack((PVOID)Thread->Tcb.StackLimit,
MmDeleteKernelStack((PVOID)Thread->Tcb.StackBase,
Thread->Tcb.LargeStack);
Thread->Tcb.InitialStack = NULL;
@ -349,7 +349,7 @@ PspDeleteThread(IN PVOID ObjectBody)
if (Thread->Tcb.InitialStack)
{
/* Release it */
MmDeleteKernelStack((PVOID)Thread->Tcb.StackLimit,
MmDeleteKernelStack((PVOID)Thread->Tcb.StackBase,
Thread->Tcb.LargeStack);
}