WaitBlock->WaitType = WaitAny;
/* Link the timer to this Wait Block */
- InitializeListHead(&Timer->Header.WaitListHead);
- InsertTailList(&Timer->Header.WaitListHead, &WaitBlock->WaitListEntry);
+ Timer->Header.WaitListHead.Flink = &WaitBlock->WaitListEntry;
+ Timer->Header.WaitListHead.Blink = &WaitBlock->WaitListEntry;
/* Create Timer */
DPRINT("Creating Timer with timeout %I64d\n", *Timeout);
InsertTailList(&Queue->Header.WaitListHead,
&WaitBlock->WaitListEntry);
- /* Block the Thread */
- DPRINT("Blocking the Thread: %x %x!\n", KeGetCurrentThread(), Thread);
- KiBlockThread(&Status,
- FALSE,
- WaitMode,
- WrQueue);
+ /* Setup the wait information */
+ Thread->WaitMode = WaitMode;
+ Thread->WaitReason = WrQueue;
+ Thread->Alertable = FALSE;
+ Thread->WaitTime = ((PLARGE_INTEGER)&KeTickCount)->LowPart;
+ Thread->State = Waiting;
+
+ /* Find a new thread to run */
+ DPRINT("Swapping threads\n");
+ Status = KiSwapThread();
/* Reset the wait reason */
Thread->WaitReason = 0;
Queue->CurrentCount++;
Thread->WaitStatus = (NTSTATUS)Entry;
- /* Remove the thread from its wait list */
- RemoveEntryList(&Thread->WaitListEntry);
-
/* Check if there's a Thread Timer */
if (Thread->Timer.Header.Inserted)
{