Author: fireball Date: Fri Sep 12 06:13:15 2008 New Revision: 36157
URL: http://svn.reactos.org/svn/reactos?rev=36157&view=rev Log: - 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
Modified: trunk/reactos/ntoskrnl/ke/i386/thrdini.c trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S trunk/reactos/ntoskrnl/ke/thrdobj.c trunk/reactos/ntoskrnl/ke/thrdschd.c trunk/reactos/ntoskrnl/mm/procsup.c trunk/reactos/ntoskrnl/ps/kill.c
Modified: trunk/reactos/ntoskrnl/ke/i386/thrdini.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/thrdini.c?... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/thrdini.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/thrdini.c [iso-8859-1] Fri Sep 12 06:13:15 2008 @@ -217,7 +217,7 @@ /* 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;
Modified: trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/usercall_a... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S [iso-8859-1] Fri Sep 12 06:13:15 2008 @@ -420,7 +420,7 @@ * @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 @@ 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]
Modified: trunk/reactos/ntoskrnl/ke/thrdobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdobj.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/ke/thrdobj.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/thrdobj.c [iso-8859-1] Fri Sep 12 06:13:15 2008 @@ -99,7 +99,7 @@ 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 @@
/* 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 @@ if (AllocatedStack) { /* Delete the stack */ - MmDeleteKernelStack((PVOID)Thread->StackLimit, FALSE); + MmDeleteKernelStack((PVOID)Thread->StackBase, FALSE); Thread->InitialStack = NULL; } } @@ -875,7 +875,7 @@ KeUninitThread(IN PKTHREAD Thread) { /* Delete the stack */ - MmDeleteKernelStack((PVOID)Thread->StackLimit, FALSE); + MmDeleteKernelStack((PVOID)Thread->StackBase, FALSE); Thread->InitialStack = NULL; }
@@ -1156,6 +1156,9 @@ /* If priority saturation happened, use the saturated increment */ 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))
Modified: trunk/reactos/ntoskrnl/ke/thrdschd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdschd.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/thrdschd.c [iso-8859-1] Fri Sep 12 06:13:15 2008 @@ -55,7 +55,7 @@ { /* 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) &&
Modified: trunk/reactos/ntoskrnl/mm/procsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/procsup.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/mm/procsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/procsup.c [iso-8859-1] Fri Sep 12 06:13:15 2008 @@ -140,15 +140,17 @@
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);
Modified: trunk/reactos/ntoskrnl/ps/kill.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/kill.c?rev=3615... ============================================================================== --- trunk/reactos/ntoskrnl/ps/kill.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/kill.c [iso-8859-1] Fri Sep 12 06:13:15 2008 @@ -188,7 +188,7 @@ 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 @@ if (Thread->Tcb.InitialStack) { /* Release it */ - MmDeleteKernelStack((PVOID)Thread->Tcb.StackLimit, + MmDeleteKernelStack((PVOID)Thread->Tcb.StackBase, Thread->Tcb.LargeStack); }