KEBUGCHECK(0);
}
-VOID
-STDCALL
-KiBlockThread(PNTSTATUS Status,
- UCHAR Alertable,
- ULONG WaitMode,
- UCHAR WaitReason)
+NTSTATUS
+NTAPI
+KiSwapThread(VOID)
{
- PKTHREAD Thread = KeGetCurrentThread();
- PKWAIT_BLOCK WaitBlock;
-
- if (Thread->ApcState.KernelApcPending) {
-
- DPRINT("Dispatching Thread as ready (APC!)\n");
-
- /* Remove Waits */
- WaitBlock = Thread->WaitBlockList;
- do {
- RemoveEntryList (&WaitBlock->WaitListEntry);
- WaitBlock = WaitBlock->NextWaitBlock;
- } while (WaitBlock != Thread->WaitBlockList);
- Thread->WaitBlockList = NULL;
-
- /* Dispatch it and return status */
- KiDispatchThreadNoLock (Ready);
- if (Status != NULL) *Status = STATUS_KERNEL_APC;
-
- } else {
+ PKTHREAD CurrentThread = KeGetCurrentThread();
- /* Set the Thread Data as Requested */
- DPRINT("Dispatching Thread as blocked: %d\n", Thread->WaitStatus);
- Thread->Alertable = Alertable;
- Thread->WaitMode = (UCHAR)WaitMode;
- Thread->WaitReason = WaitReason;
+ /* Find a new thread to run */
+ DPRINT("Dispatching Thread as blocked\n");
+ KiDispatchThreadNoLock(Waiting);
- /* Dispatch it and return status */
- KiDispatchThreadNoLock(Waiting);
- DPRINT("Dispatching Thread as blocked: %d\n", Thread->WaitStatus);
- if (Status != NULL) *Status = Thread->WaitStatus;
- }
+ /* Lower IRQL back */
+ DPRINT("Lowering IRQL \n");
+ KfLowerIrql(CurrentThread->WaitIrql);
- DPRINT("Releasing Dispatcher Lock\n");
- KfLowerIrql(Thread->WaitIrql);
+ /* Return the wait status */
+ return CurrentThread->WaitStatus;
}
VOID
DPRINT("Initializing Dispatcher Header for New Thread: %x in Process: %x\n", Thread, Process);
KeInitializeDispatcherHeader(&Thread->DispatcherHeader,
ThreadObject,
- sizeof(KTHREAD),
+ sizeof(KTHREAD) / sizeof(LONG),
FALSE);
DPRINT("Thread Header Created. SystemRoutine: %x, StartRoutine: %x with Context: %x\n",
}
/*
- * Sets thread's base priority relative to the process' base priority
- * Should only be passed in THREAD_PRIORITY_ constants in pstypes.h
- *
* @implemented
*/
LONG
STDCALL
-KeSetBasePriorityThread (PKTHREAD Thread,
- LONG Increment)
+KeSetBasePriorityThread(PKTHREAD Thread,
+ LONG Increment)
{
KIRQL OldIrql;
PKPROCESS Process;