- Rename kqueue.c to devque. KQUEUE (kernel queues) are implemented in queue.c, and this filename always confused me. Why would you name KDEVICE_QUEUE into kqueue.c, when you already have KQUEUE in queue.c?!

- Rename exception.c to except.c, mostly due to MSVC's incompatibility with multiple identically named files.
- SVN delete usercall.c leftover.
- Fix KeSetPriorityAndQuantumProcess to use Queued Spinlocks and KiAcquireProcess/ThreadLock when needed.

svn path=/trunk/; revision=24094
This commit is contained in:
Alex Ionescu 2006-09-13 03:02:40 +00:00
parent 630f3d1e69
commit 63142230b2
6 changed files with 29 additions and 117 deletions

View File

@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ke/kqueue.c
* FILE: ntoskrnl/ke/devqueue.c
* PURPOSE: Implement device queues
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/

View File

@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ke/exception.c
* FILE: ntoskrnl/ke/except.c
* PURPOSE: Platform independent exception handling
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/

View File

@ -261,27 +261,23 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
IN KPRIORITY Priority,
IN UCHAR Quantum OPTIONAL)
{
KLOCK_QUEUE_HANDLE ProcessLock;
KPRIORITY Delta;
PLIST_ENTRY NextEntry, ListHead;
KPRIORITY NewPriority, OldPriority;
KIRQL OldIrql;
PKTHREAD Thread;
BOOLEAN Released;
ASSERT_PROCESS(Process);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
/* Check if the process already has this priority */
if (Process->BasePriority == Priority)
{
/* Don't change anything */
return Process->BasePriority;
}
if (Process->BasePriority == Priority) return Process->BasePriority;
/* If the caller gave priority 0, normalize to 1 */
if (!Priority) Priority = 1;
if (!LOW_PRIORITY) Priority = LOW_PRIORITY + 1;
/* Lock Dispatcher */
OldIrql = KiAcquireDispatcherLock();
/* Lock the process */
KiAcquireProcessLock(Process, &ProcessLock);
/* Check if we are modifying the quantum too */
if (Quantum) Process->QuantumReset = Quantum;
@ -309,6 +305,9 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
/* Update the quantum if we had one */
if (Quantum) Thread->QuantumReset = Quantum;
/* Acquire the thread lock */
KiAcquireThreadLock(Thread);
/* Calculate the new priority */
NewPriority = Thread->BasePriority + Delta;
if (NewPriority < LOW_REALTIME_PRIORITY)
@ -349,6 +348,9 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
KiSetPriorityThread(Thread, NewPriority, &Released);
}
/* Release the thread lock */
KiReleaseThreadLock(Thread);
/* Go to the next thread */
NextEntry = NextEntry->Flink;
}
@ -364,6 +366,9 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
/* Update the quantum if we had one */
if (Quantum) Thread->QuantumReset = Quantum;
/* Lock the thread */
KiAcquireThreadLock(Thread);
/* Calculate the new priority */
NewPriority = Thread->BasePriority + Delta;
if (NewPriority >= LOW_REALTIME_PRIORITY)
@ -405,13 +410,20 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
KiSetPriorityThread(Thread, NewPriority, &Released);
}
/* Release the thread lock */
KiReleaseThreadLock(Thread);
/* Go to the next thread */
NextEntry = NextEntry->Flink;
}
}
/* Release Dispatcher Database */
if (!Released) KiReleaseDispatcherLock(OldIrql);
if (!Released) KiReleaseDispatcherLockFromDpcLevel();
/* Release the process lock */
KiReleaseProcessLockFromDpcLevel(&ProcessLock);
KiExitDispatcher(ProcessLock.OldIrql);
/* Return previous priority */
return OldPriority;

View File

@ -69,7 +69,7 @@ LONG
NTAPI
KiInsertQueue(IN PKQUEUE Queue,
IN PLIST_ENTRY Entry,
BOOLEAN Head)
IN BOOLEAN Head)
{
ULONG InitialState;
PKTHREAD Thread = KeGetCurrentThread();
@ -103,10 +103,10 @@ KiInsertQueue(IN PKQUEUE Queue,
/* Remove the queue from the thread's wait list */
Thread->WaitStatus = (NTSTATUS)Entry;
if (Thread->WaitListEntry.Flink) RemoveEntryList(&Thread->WaitListEntry);
Thread->WaitReason = 0;
/* Increase the active threads and set the status*/
/* Increase the active threads and remove any wait reason */
Queue->CurrentCount++;
Thread->WaitReason = 0;
/* Check if there's a Thread Timer */
if (Thread->Timer.Header.Inserted)

View File

@ -1,100 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/usercall.c
* PURPOSE: User-Mode callbacks. Portable part.
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
NTSTATUS
STDCALL
KiCallUserMode(
IN PVOID *OutputBuffer,
IN PULONG OutputLength
);
PULONG
STDCALL
KiGetUserModeStackAddress(
VOID
);
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
NTSTATUS
STDCALL
KeUserModeCallback(IN ULONG RoutineIndex,
IN PVOID Argument,
IN ULONG ArgumentLength,
OUT PVOID *Result,
OUT PULONG ResultLength)
{
ULONG_PTR NewStack, OldStack;
PULONG UserEsp;
NTSTATUS CallbackStatus = STATUS_SUCCESS;
PEXCEPTION_REGISTRATION_RECORD ExceptionList;
DPRINT("KeUserModeCallback(RoutineIndex %d, Argument %X, ArgumentLength %d)\n",
RoutineIndex, Argument, ArgumentLength);
ASSERT(KeGetCurrentThread()->ApcState.KernelApcInProgress == FALSE);
ASSERT(KeGetPreviousMode() == UserMode);
/* Get the current user-mode stack */
UserEsp = KiGetUserModeStackAddress();
OldStack = *UserEsp;
/* Enter a SEH Block */
_SEH_TRY
{
/* Calculate and align the stack size */
NewStack = (OldStack - ArgumentLength) & ~3;
/* Make sure it's writable */
ProbeForWrite((PVOID)(NewStack - 6 * sizeof(ULONG_PTR)),
ArgumentLength + 6 * sizeof(ULONG_PTR),
sizeof(CHAR));
/* Copy the buffer into the stack */
RtlCopyMemory((PVOID)NewStack, Argument, ArgumentLength);
/* Write the arguments */
NewStack -= 24;
*(PULONG)NewStack = 0;
*(PULONG)(NewStack + 4) = RoutineIndex;
*(PULONG)(NewStack + 8) = (NewStack + 24);
*(PULONG)(NewStack + 12) = ArgumentLength;
/* Save the exception list */
ExceptionList = KeGetCurrentThread()->Teb->Tib.ExceptionList;
/* Jump to user mode */
*UserEsp = NewStack;
CallbackStatus = KiCallUserMode(Result, ResultLength);
/* FIXME: Handle user-mode exception status */
/* Restore exception list */
KeGetCurrentThread()->Teb->Tib.ExceptionList = ExceptionList;
}
_SEH_HANDLE
{
CallbackStatus = _SEH_GetExceptionCode();
}
_SEH_END;
/* FIXME: Flush GDI Batch */
/* Restore stack and return */
*UserEsp = OldStack;
return CallbackStatus;
}
/* EOF */

View File

@ -49,14 +49,14 @@
<file>bug.c</file>
<file>clock.c</file>
<file>config.c</file>
<file>devqueue.c</file>
<file>dpc.c</file>
<file>event.c</file>
<file>exception.c</file>
<file>except.c</file>
<file>freeldr.c</file>
<file>gate.c</file>
<file>gmutex.c</file>
<file>ipi.c</file>
<file>kqueue.c</file>
<file>krnlinit.c</file>
<file>mutex.c</file>
<file>process.c</file>