} \\r
}\r
\r
+//\r
+// Recalculates the due time\r
+//\r
+PLARGE_INTEGER\r
+FORCEINLINE\r
+KiRecalculateDueTime(IN PLARGE_INTEGER OriginalDueTime,\r
+ IN PLARGE_INTEGER DueTime,\r
+ IN OUT PLARGE_INTEGER NewDueTime)\r
+{\r
+ /* Don't do anything for absolute waits */\r
+ if (OriginalDueTime->QuadPart >= 0) return OriginalDueTime;\r
+\r
+ /* Otherwise, query the interrupt time and recalculate */\r
+ NewDueTime->QuadPart = KeQueryInterruptTime();\r
+ NewDueTime->QuadPart -= DueTime->QuadPart;\r
+ return NewDueTime;\r
+}\r
+\r
//\r
// Determines wether a thread should be added to the wait list\r
//\r
PKWAIT_BLOCK WaitBlock;
PKTIMER Timer;
BOOLEAN Swappable;
+ PLARGE_INTEGER OriginalDueTime = Timeout;
+ LARGE_INTEGER DueTime, NewDueTime;
ASSERT_QUEUE(Queue);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
&Timer->Header.WaitListHead;
/* Create Timer */
- KiInsertTimer(Timer, *Timeout);
+ if (!KiInsertTimer(Timer, *Timeout))
+ {
+ /* FIXME */
+ DPRINT1("If you see thie message contact Alex ASAP\n");
+ KEBUGCHECK(0);
+ }
+
+ /* Set timer due time */
+ DueTime.QuadPart = Timer->DueTime.QuadPart;
}
/* Close the loop */
/* Check if we had a timeout */
if (Timeout)
{
- DPRINT1("If you see this message, contact Alex ASAP\n");
- KEBUGCHECK(0);
+ /* Recalculate due times */
+ Timeout = KiRecalculateDueTime(OriginalDueTime,
+ &DueTime,
+ &NewDueTime);
}
}
PKTHREAD CurrentThread = KeGetCurrentThread();
NTSTATUS WaitStatus = STATUS_SUCCESS;
BOOLEAN Swappable;
+ PLARGE_INTEGER OriginalDueTime = Interval;
+ LARGE_INTEGER DueTime, NewDueTime;
/* Check if the lock is already held */
if (CurrentThread->WaitNext)
break;
}
+ /* Save due time */
+ DueTime.QuadPart = ThreadTimer->DueTime.QuadPart;
+
/* Handle Kernel Queues */
if (CurrentThread->Queue) KiWakeQueue(CurrentThread->Queue);
return WaitStatus;
}
- /* Check if we had a timeout */
- DPRINT1("If you see this message, contact Alex ASAP\n");
- KEBUGCHECK(0);
+ /* Recalculate due times */
+ Interval = KiRecalculateDueTime(OriginalDueTime,
+ &DueTime,
+ &NewDueTime);
}
/* Acquire again the lock */
PKTHREAD CurrentThread = KeGetCurrentThread();
NTSTATUS WaitStatus = STATUS_SUCCESS;
BOOLEAN Swappable;
+ LARGE_INTEGER DueTime, NewDueTime;
+ PLARGE_INTEGER OriginalDueTime = Timeout;
/* Check if the lock is already held */
if (CurrentThread->WaitNext)
WaitStatus = STATUS_TIMEOUT;
goto DontWait;
}
+
+ /* Set the current due time */
+ DueTime.QuadPart = ThreadTimer->DueTime.QuadPart;
}
else
{
/* Check if we had a timeout */
if (Timeout)
{
- DPRINT1("If you see this message, contact Alex ASAP\n");
- KEBUGCHECK(0);
+ /* Recalculate due times */
+ Timeout = KiRecalculateDueTime(OriginalDueTime,
+ &DueTime,
+ &NewDueTime);
}
}
ULONG WaitIndex;
NTSTATUS WaitStatus = STATUS_SUCCESS;
BOOLEAN Swappable;
+ PLARGE_INTEGER OriginalDueTime = Timeout;
+ LARGE_INTEGER DueTime, NewDueTime;
/* Set the Current Thread */
CurrentThread = KeGetCurrentThread();
WaitStatus = STATUS_TIMEOUT;
goto DontWait;
}
+
+ /* Set the current due time */
+ DueTime.QuadPart = ThreadTimer->DueTime.QuadPart;
}
/* Insert into Object's Wait List*/
/* Check if we had a timeout */
if (Timeout)
{
- DPRINT1("If you see this message, contact Alex ASAP\n");
- KEBUGCHECK(0);
+ /* Recalculate due times */
+ Timeout = KiRecalculateDueTime(OriginalDueTime,
+ &DueTime,
+ &NewDueTime);
}
/* Acquire again the lock */