00193 :
00194
00195 This function inserts a timer object in
the timer table.
00196
00197 N.B. This routine assumes that
the dispatcher data lock has been acquired.
00198
00199 Arguments:
00200
00201 Interval - Supplies
the relative timer before
the timer
is to expire.
00202
00203 CurrentTime - supplies
the current interrupt time.
00204
00205 Timer - Supplies a pointer to a dispatcher object of
type timer.
00206
00207 Return Value:
00208
00209 If
the timer
is inserted in
the timer tree, than a value of
TRUE is
00210 returned. Otherwise, a value of
FALSE is returned.
00211
00212 --*/
00213
00214 {
00215
00216 ULONG
Index;
00217 PLIST_ENTRY ListHead;
00218 PLIST_ENTRY NextEntry;
00219
PRKTIMER NextTimer;
00220 ULONG SearchCount;
00221
00222
00223
00224
00225
00226
Index =
KiComputeTimerTableIndex(Interval, CurrentTime, Timer);
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 ListHead = &
KiTimerTableListHead[
Index];
00242 NextEntry = ListHead->Blink;
00243
00244
#if DBG
00245
00246 SearchCount = 0;
00247
00248
#endif
00249
00250
while (NextEntry != ListHead) {
00251
00252
00253
00254
00255
00256
#if DBG
00257
00258 SearchCount += 1;
00259
if (SearchCount >
KiMaximumSearchCount) {
00260
KiMaximumSearchCount = SearchCount;
00261 }
00262
00263
#endif
00264
00265 NextTimer = CONTAINING_RECORD(NextEntry,
KTIMER, TimerListEntry);
00266
if (((Timer->DueTime.HighPart == NextTimer->
DueTime.HighPart) &&
00267 (Timer->DueTime.LowPart >= NextTimer->
DueTime.LowPart)) ||
00268 (Timer->DueTime.HighPart > NextTimer->
DueTime.HighPart)) {
00269 InsertHeadList(NextEntry, &Timer->TimerListEntry);
00270
return TRUE;
00271 }
00272
00273 NextEntry = NextEntry->Blink;
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 InsertHeadList(ListHead, &Timer->TimerListEntry);
00290 KiQueryInterruptTime(&CurrentTime);
00291
if (((Timer->DueTime.HighPart == (ULONG)CurrentTime.HighPart) &&
00292 (Timer->DueTime.LowPart <= CurrentTime.LowPart)) ||
00293 (Timer->DueTime.HighPart < (ULONG)CurrentTime.HighPart)) {
00294
00295
00296
00297
00298
00299
00300
00301
KiRemoveTreeTimer(Timer);
00302 Timer->Header.SignalState =
TRUE;
00303 }
00304
00305
return Timer->Header.Inserted;
00306 }
}