00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
#include "ki.h"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #define TestForAlertPending(Alertable) \
00058
if (Alertable) { \
00059
if (Thread->Alerted[WaitMode] != FALSE) { \
00060
Thread->Alerted[WaitMode] = FALSE; \
00061
WaitStatus = STATUS_ALERTED; \
00062
break; \
00063
} else if ((WaitMode != KernelMode) && \
00064
(IsListEmpty(&Thread->ApcState.ApcListHead[UserMode])) == FALSE) { \
00065
Thread->ApcState.UserApcPending = TRUE; \
00066
WaitStatus = STATUS_USER_APC; \
00067
break; \
00068
} else if (Thread->Alerted[KernelMode] != FALSE) { \
00069
Thread->Alerted[KernelMode] = FALSE; \
00070
WaitStatus = STATUS_ALERTED; \
00071
break; \
00072
} \
00073
} else if ((WaitMode != KernelMode) && (Thread->ApcState.UserApcPending)) { \
00074
WaitStatus = STATUS_USER_APC; \
00075
break; \
00076
}
00077
00078
VOID
00079 KiAdjustQuantumThread (
00080 IN
PKTHREAD Thread
00081 )
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 {
00102 PKPRCB Prcb;
00103
PKPROCESS Process;
00104
PKTHREAD NewThread;
00105 SCHAR ThreadPriority;
00106
00107
if ((Thread->Priority < LOW_REALTIME_PRIORITY) &&
00108 (Thread->BasePriority <
TIME_CRITICAL_PRIORITY_BOUND)) {
00109 Thread->Quantum -=
WAIT_QUANTUM_DECREMENT;
00110
if (Thread->Quantum <= 0) {
00111 Process = Thread->ApcState.Process;
00112 Thread->Quantum = Process->
ThreadQuantum;
00113 ThreadPriority = Thread->Priority - (Thread->PriorityDecrement + 1);
00114
if (ThreadPriority < Thread->BasePriority) {
00115 ThreadPriority = Thread->BasePriority;
00116 }
00117
00118 Thread->PriorityDecrement = 0;
00119
if (ThreadPriority != Thread->Priority) {
00120
KiSetPriorityThread(Thread, ThreadPriority);
00121
00122 }
else {
00123 Prcb =
KeGetCurrentPrcb();
00124
if (Prcb->NextThread ==
NULL) {
00125 NewThread =
KiFindReadyThread(Thread->NextProcessor,
00126 ThreadPriority);
00127
if (NewThread !=
NULL) {
00128 Prcb->NextThread = NewThread;
00129 NewThread->
State =
Standby;
00130 }
00131 }
00132 }
00133 }
00134 }
00135
00136
return;
00137 }
00138
00139
NTSTATUS
00140 KeDelayExecutionThread (
00141 IN KPROCESSOR_MODE WaitMode,
00142 IN BOOLEAN Alertable,
00143 IN PLARGE_INTEGER Interval
00144 )
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 {
00174
00175 LARGE_INTEGER DueTime;
00176 LARGE_INTEGER NewTime;
00177 PLARGE_INTEGER OriginalTime;
00178 PKPRCB Prcb;
00179 KPRIORITY Priority;
00180
PRKQUEUE Queue;
00181
PRKTHREAD Thread;
00182
PRKTIMER Timer;
00183
PKWAIT_BLOCK WaitBlock;
00184
NTSTATUS WaitStatus;
00185
00186
00187
00188
00189
00190
00191
00192 Thread =
KeGetCurrentThread();
00193
if (Thread->
WaitNext) {
00194 Thread->
WaitNext =
FALSE;
00195
00196 }
else {
00197
KiLockDispatcherDatabase(&Thread->
WaitIrql);
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 OriginalTime = Interval;
00209 WaitBlock = &Thread->
WaitBlock[
TIMER_WAIT_BLOCK];
00210
do {
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
if (Thread->
ApcState.
KernelApcPending && (Thread->
WaitIrql <
APC_LEVEL)) {
00224
00225
00226
00227
00228
00229
00230
00231
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00232
00233 }
else {
00234
00235
00236
00237
00238
00239
TestForAlertPending(Alertable);
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 Thread->
WaitBlockList = WaitBlock;
00253 Thread->
WaitStatus = (
NTSTATUS)0;
00254 Timer = &Thread->
Timer;
00255 WaitBlock->
NextWaitBlock = WaitBlock;
00256 Timer->
Header.
WaitListHead.Flink = &WaitBlock->
WaitListEntry;
00257 Timer->
Header.
WaitListHead.Blink = &WaitBlock->
WaitListEntry;
00258
00259
00260
00261
00262
00263
00264
00265
if (
KiInsertTreeTimer(Timer, *Interval) ==
FALSE) {
00266
00267
00268
00269
00270
00271
00272 Prcb =
KeGetCurrentPrcb();
00273 Priority = Thread->
Priority;
00274
if (Priority < LOW_REALTIME_PRIORITY) {
00275
if (Priority != Thread->
BasePriority) {
00276 Thread->
PriorityDecrement = 0;
00277
KiSetPriorityThread(Thread, Thread->
BasePriority);
00278 }
00279 }
00280
00281
00282
00283
00284
00285
00286
if (Prcb->NextThread ==
NULL) {
00287 Prcb->NextThread =
KiFindReadyThread(Thread->
NextProcessor,
00288 Thread->
Priority);
00289 }
00290
00291
00292
00293
00294
00295
00296
if (Prcb->NextThread !=
NULL) {
00297
00298
00299
00300
00301
00302
00303
00304
00305 Thread->
Preempted =
FALSE;
00306 Thread->
Quantum = Thread->
ApcState.
Process->
ThreadQuantum;
00307
00308
ASSERT(Thread->
WaitIrql <=
DISPATCH_LEVEL);
00309
00310
KiReadyThread(Thread);
00311 WaitStatus = (
NTSTATUS)
KiSwapThread();
00312
goto WaitComplete;
00313
00314 }
else {
00315 WaitStatus = (
NTSTATUS)STATUS_SUCCESS;
00316
break;
00317 }
00318 }
00319
00320 DueTime.QuadPart = Timer->
DueTime.QuadPart;
00321
00322
00323
00324
00325
00326
00327 Queue = Thread->
Queue;
00328
if (Queue !=
NULL) {
00329
KiActivateWaiterQueue(Queue);
00330 }
00331
00332
00333
00334
00335
00336
00337 Thread->
Alertable = Alertable;
00338 Thread->
WaitMode = WaitMode;
00339 Thread->
WaitReason =
DelayExecution;
00340 Thread->
WaitTime= KiQueryLowTickCount();
00341 Thread->
State =
Waiting;
00342
KiInsertWaitList(WaitMode, Thread);
00343
00344
00345
00346
00347
00348
00349
00350
ASSERT(Thread->
WaitIrql <=
DISPATCH_LEVEL);
00351
00352 WaitStatus = (
NTSTATUS)
KiSwapThread();
00353
00354
00355
00356
00357
00358
00359 WaitComplete:
00360
if (WaitStatus != STATUS_KERNEL_APC) {
00361
if (WaitStatus == STATUS_TIMEOUT) {
00362 WaitStatus = STATUS_SUCCESS;
00363 }
00364
00365
return WaitStatus;
00366 }
00367
00368
00369
00370
00371
00372 Interval =
KiComputeWaitInterval(OriginalTime,
00373 &DueTime,
00374 &NewTime);
00375 }
00376
00377
00378
00379
00380
00381
KiLockDispatcherDatabase(&Thread->
WaitIrql);
00382 }
while (
TRUE);
00383
00384
00385
00386
00387
00388
00389
00390
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00391
return WaitStatus;
00392 }
00393
00394
NTSTATUS
00395 KeWaitForMultipleObjects (
00396 IN ULONG Count,
00397 IN PVOID Object[],
00398 IN WAIT_TYPE WaitType,
00399 IN
KWAIT_REASON WaitReason,
00400 IN KPROCESSOR_MODE WaitMode,
00401 IN BOOLEAN Alertable,
00402 IN PLARGE_INTEGER Timeout OPTIONAL,
00403 IN
PKWAIT_BLOCK WaitBlockArray OPTIONAL
00404 )
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 {
00455
00456 LARGE_INTEGER DueTime;
00457 ULONG
Index;
00458 LARGE_INTEGER NewTime;
00459
PRKTHREAD NextThread;
00460
PKMUTANT Objectx;
00461 PLARGE_INTEGER OriginalTime;
00462
PRKQUEUE Queue;
00463
PRKTHREAD Thread;
00464
PRKTIMER Timer;
00465
PRKWAIT_BLOCK WaitBlock;
00466 BOOLEAN WaitSatisfied;
00467
NTSTATUS WaitStatus;
00468
PKWAIT_BLOCK WaitTimer;
00469
00470
00471
00472
00473
00474
00475
00476 Thread =
KeGetCurrentThread();
00477
if (Thread->
WaitNext) {
00478 Thread->
WaitNext =
FALSE;
00479
00480 }
else {
00481
KiLockDispatcherDatabase(&Thread->
WaitIrql);
00482 }
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
if (ARGUMENT_PRESENT(WaitBlockArray)) {
00494
if (
Count > MAXIMUM_WAIT_OBJECTS) {
00495
KeBugCheck(MAXIMUM_WAIT_OBJECTS_EXCEEDED);
00496 }
00497
00498 }
else {
00499
if (
Count >
THREAD_WAIT_OBJECTS) {
00500
KeBugCheck(MAXIMUM_WAIT_OBJECTS_EXCEEDED);
00501 }
00502
00503 WaitBlockArray = &Thread->
WaitBlock[0];
00504 }
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 OriginalTime = Timeout;
00515
do {
00516
00517
00518
00519
00520
00521 Thread->
WaitBlockList = WaitBlockArray;
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
if (Thread->
ApcState.
KernelApcPending && (Thread->
WaitIrql <
APC_LEVEL)) {
00535
00536
00537
00538
00539
00540
00541
00542
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00543
00544 }
else {
00545
00546
00547
00548
00549
00550
00551
00552
00553 Thread->
WaitStatus = (
NTSTATUS)0;
00554 WaitSatisfied =
TRUE;
00555
for (
Index = 0;
Index <
Count;
Index += 1) {
00556
00557
00558
00559
00560
00561 Objectx = (
PKMUTANT)Object[
Index];
00562
00563
ASSERT(Objectx->
Header.
Type !=
QueueObject);
00564
00565
if (WaitType == WaitAny) {
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
if (Objectx->
Header.
Type ==
MutantObject) {
00576
if ((Objectx->
Header.
SignalState > 0) ||
00577 (Thread == Objectx->
OwnerThread)) {
00578
if (Objectx->
Header.
SignalState != MINLONG) {
00579
KiWaitSatisfyMutant(Objectx, Thread);
00580 WaitStatus = (
NTSTATUS)(
Index | Thread->
WaitStatus);
00581
goto NoWait;
00582
00583 }
else {
00584
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00585
ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED);
00586 }
00587 }
00588
00589
00590
00591
00592
00593
00594 }
else if (Objectx->
Header.
SignalState > 0) {
00595
KiWaitSatisfyOther(Objectx);
00596 WaitStatus = (
NTSTATUS)(
Index);
00597
goto NoWait;
00598 }
00599
00600 }
else {
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
if (Objectx->
Header.
Type ==
MutantObject) {
00612
if ((Thread == Objectx->
OwnerThread) &&
00613 (Objectx->
Header.
SignalState == MINLONG)) {
00614
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00615
ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED);
00616
00617 }
else if ((Objectx->
Header.
SignalState <= 0) &&
00618 (Thread != Objectx->
OwnerThread)) {
00619 WaitSatisfied =
FALSE;
00620 }
00621
00622
00623
00624
00625
00626
00627 }
else if (Objectx->
Header.
SignalState <= 0) {
00628 WaitSatisfied =
FALSE;
00629 }
00630 }
00631
00632
00633
00634
00635
00636 WaitBlock = &WaitBlockArray[
Index];
00637 WaitBlock->
Object = (PVOID)Objectx;
00638 WaitBlock->
WaitKey = (CSHORT)(
Index);
00639 WaitBlock->
WaitType = (
USHORT)WaitType;
00640 WaitBlock->
Thread = Thread;
00641 WaitBlock->
NextWaitBlock = &WaitBlockArray[
Index + 1];
00642 }
00643
00644
00645
00646
00647
00648
00649
if ((WaitType == WaitAll) && (WaitSatisfied)) {
00650 WaitBlock->
NextWaitBlock = &WaitBlockArray[0];
00651
KiWaitSatisfyAll(WaitBlock);
00652 WaitStatus = (
NTSTATUS)Thread->
WaitStatus;
00653
goto NoWait;
00654 }
00655
00656
00657
00658
00659
00660
TestForAlertPending(Alertable);
00661
00662
00663
00664
00665
00666
00667
if (ARGUMENT_PRESENT(Timeout)) {
00668
00669
00670
00671
00672
00673
00674
if (!(Timeout->LowPart | Timeout->HighPart)) {
00675 WaitStatus = (
NTSTATUS)(STATUS_TIMEOUT);
00676
goto NoWait;
00677 }
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 WaitTimer = &Thread->
WaitBlock[
TIMER_WAIT_BLOCK];
00691 WaitBlock->
NextWaitBlock = WaitTimer;
00692 WaitBlock = WaitTimer;
00693 Timer = &Thread->
Timer;
00694 InitializeListHead(&Timer->
Header.
WaitListHead);
00695
if (
KiInsertTreeTimer(Timer, *Timeout) ==
FALSE) {
00696 WaitStatus = (
NTSTATUS)STATUS_TIMEOUT;
00697
goto NoWait;
00698 }
00699
00700 DueTime.QuadPart = Timer->
DueTime.QuadPart;
00701 }
00702
00703
00704
00705
00706
00707 WaitBlock->
NextWaitBlock = &WaitBlockArray[0];
00708
00709
00710
00711
00712
00713 WaitBlock = &WaitBlockArray[0];
00714
do {
00715 Objectx = (
PKMUTANT)WaitBlock->
Object;
00716 InsertTailList(&Objectx->
Header.
WaitListHead, &WaitBlock->
WaitListEntry);
00717 WaitBlock = WaitBlock->
NextWaitBlock;
00718 }
while (WaitBlock != &WaitBlockArray[0]);
00719
00720
00721
00722
00723
00724
00725 Queue = Thread->
Queue;
00726
if (Queue !=
NULL) {
00727
KiActivateWaiterQueue(Queue);
00728 }
00729
00730
00731
00732
00733
00734
00735 Thread->
Alertable = Alertable;
00736 Thread->
WaitMode = WaitMode;
00737 Thread->
WaitReason = (UCHAR)WaitReason;
00738 Thread->
WaitTime= KiQueryLowTickCount();
00739 Thread->
State =
Waiting;
00740
KiInsertWaitList(WaitMode, Thread);
00741
00742
00743
00744
00745
00746
00747
00748
ASSERT(Thread->
WaitIrql <=
DISPATCH_LEVEL);
00749
00750 WaitStatus = (
NTSTATUS)
KiSwapThread();
00751
00752
00753
00754
00755
00756
00757
if (WaitStatus != STATUS_KERNEL_APC) {
00758
return WaitStatus;
00759 }
00760
00761
if (ARGUMENT_PRESENT(Timeout)) {
00762
00763
00764
00765
00766
00767 Timeout =
KiComputeWaitInterval(OriginalTime,
00768 &DueTime,
00769 &NewTime);
00770 }
00771 }
00772
00773
00774
00775
00776
00777
KiLockDispatcherDatabase(&Thread->
WaitIrql);
00778 }
while (
TRUE);
00779
00780
00781
00782
00783
00784
00785
00786
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00787
return WaitStatus;
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797 NoWait:
00798
KiAdjustQuantumThread(Thread);
00799
00800
00801
00802
00803
00804
00805
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00806
return WaitStatus;
00807 }
00808
00809
NTSTATUS
00810 KeWaitForSingleObject (
00811 IN PVOID Object,
00812 IN KWAIT_REASON WaitReason,
00813 IN KPROCESSOR_MODE WaitMode,
00814 IN BOOLEAN Alertable,
00815 IN PLARGE_INTEGER Timeout OPTIONAL
00816 )
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856 {
00857
00858 LARGE_INTEGER DueTime;
00859 LARGE_INTEGER NewTime;
00860
PRKTHREAD NextThread;
00861
PKMUTANT Objectx;
00862 PLARGE_INTEGER OriginalTime;
00863
PRKQUEUE Queue;
00864
PRKTHREAD Thread;
00865
PRKTIMER Timer;
00866
PKWAIT_BLOCK WaitBlock;
00867
NTSTATUS WaitStatus;
00868
PKWAIT_BLOCK WaitTimer;
00869
00870
00871
00872
00873
00874
#if defined(_COLLECT_WAIT_SINGLE_CALLDATA_)
00875
00876
RECORD_CALL_DATA(&
KiWaitSingleCallData);
00877
00878
#endif
00879
00880
00881
00882
00883
00884
00885
00886 Thread =
KeGetCurrentThread();
00887
if (Thread->
WaitNext) {
00888 Thread->
WaitNext =
FALSE;
00889
00890 }
else {
00891
KiLockDispatcherDatabase(&Thread->
WaitIrql);
00892 }
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902 OriginalTime = Timeout;
00903 WaitBlock = &Thread->
WaitBlock[0];
00904
do {
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
if (Thread->
ApcState.
KernelApcPending && (Thread->
WaitIrql <
APC_LEVEL)) {
00918
00919
00920
00921
00922
00923
00924
00925
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00926
00927 }
else {
00928
00929
00930
00931
00932
00933 Objectx = (
PKMUTANT)Object;
00934 Thread->
WaitStatus = (
NTSTATUS)0;
00935
00936
ASSERT(Objectx->
Header.
Type !=
QueueObject);
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
if (Objectx->
Header.
Type ==
MutantObject) {
00947
if ((Objectx->
Header.
SignalState > 0) ||
00948 (Thread == Objectx->
OwnerThread)) {
00949
if (Objectx->
Header.
SignalState != MINLONG) {
00950
KiWaitSatisfyMutant(Objectx, Thread);
00951 WaitStatus = (
NTSTATUS)(Thread->
WaitStatus);
00952
goto NoWait;
00953
00954 }
else {
00955
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
00956
ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED);
00957 }
00958 }
00959
00960
00961
00962
00963
00964 }
else if (Objectx->
Header.
SignalState > 0) {
00965
KiWaitSatisfyOther(Objectx);
00966 WaitStatus = (
NTSTATUS)(0);
00967
goto NoWait;
00968 }
00969
00970
00971
00972
00973
00974 Thread->
WaitBlockList = WaitBlock;
00975 WaitBlock->
Object = Object;
00976 WaitBlock->
WaitKey = (CSHORT)(STATUS_SUCCESS);
00977 WaitBlock->
WaitType = WaitAny;
00978
00979
00980
00981
00982
00983
TestForAlertPending(Alertable);
00984
00985
00986
00987
00988
00989
00990
if (ARGUMENT_PRESENT(Timeout)) {
00991
00992
00993
00994
00995
00996
00997
if (!(Timeout->LowPart | Timeout->HighPart)) {
00998 WaitStatus = (
NTSTATUS)(STATUS_TIMEOUT);
00999
goto NoWait;
01000 }
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013 Timer = &Thread->
Timer;
01014 WaitTimer = &Thread->
WaitBlock[
TIMER_WAIT_BLOCK];
01015 WaitBlock->
NextWaitBlock = WaitTimer;
01016 Timer->
Header.
WaitListHead.Flink = &WaitTimer->
WaitListEntry;
01017 Timer->
Header.
WaitListHead.Blink = &WaitTimer->
WaitListEntry;
01018 WaitTimer->
NextWaitBlock = WaitBlock;
01019
if (
KiInsertTreeTimer(Timer, *Timeout) ==
FALSE) {
01020 WaitStatus = (
NTSTATUS)STATUS_TIMEOUT;
01021
goto NoWait;
01022 }
01023
01024 DueTime.QuadPart = Timer->
DueTime.QuadPart;
01025
01026 }
else {
01027 WaitBlock->
NextWaitBlock = WaitBlock;
01028 }
01029
01030
01031
01032
01033
01034 InsertTailList(&Objectx->
Header.
WaitListHead, &WaitBlock->
WaitListEntry);
01035
01036
01037
01038
01039
01040
01041 Queue = Thread->
Queue;
01042
if (Queue !=
NULL) {
01043
KiActivateWaiterQueue(Queue);
01044 }
01045
01046
01047
01048
01049
01050
01051 Thread->
Alertable = Alertable;
01052 Thread->
WaitMode = WaitMode;
01053 Thread->
WaitReason = (UCHAR)WaitReason;
01054 Thread->
WaitTime= KiQueryLowTickCount();
01055 Thread->
State =
Waiting;
01056
KiInsertWaitList(WaitMode, Thread);
01057
01058
01059
01060
01061
01062
01063
01064
ASSERT(Thread->
WaitIrql <=
DISPATCH_LEVEL);
01065
01066 WaitStatus = (
NTSTATUS)
KiSwapThread();
01067
01068
01069
01070
01071
01072
01073
if (WaitStatus != STATUS_KERNEL_APC) {
01074
return WaitStatus;
01075 }
01076
01077
if (ARGUMENT_PRESENT(Timeout)) {
01078
01079
01080
01081
01082
01083 Timeout =
KiComputeWaitInterval(OriginalTime,
01084 &DueTime,
01085 &NewTime);
01086 }
01087 }
01088
01089
01090
01091
01092
01093
KiLockDispatcherDatabase(&Thread->
WaitIrql);
01094 }
while (
TRUE);
01095
01096
01097
01098
01099
01100
01101
01102
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
01103
return WaitStatus;
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113 NoWait:
01114
KiAdjustQuantumThread(Thread);
01115
01116
01117
01118
01119
01120
01121
KiUnlockDispatcherDatabase(Thread->
WaitIrql);
01122
return WaitStatus;
01123 }
01124
01125
NTSTATUS
01126 KiSetServerWaitClientEvent (
01127 IN
PKEVENT ServerEvent,
01128 IN
PKEVENT ClientEvent,
01129 IN ULONG WaitMode
01130 )
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159 {
01160
01161
01162
01163
01164
01165
KeSetEvent(ServerEvent,
EVENT_INCREMENT,
TRUE);
01166
return KeWaitForSingleObject(ClientEvent,
01167
WrEventPair,
01168 (
KPROCESSOR_MODE)WaitMode,
01169
FALSE,
01170
NULL);
01171 }
01172
01173 PLARGE_INTEGER
01174
FASTCALL
01175 KiComputeWaitInterval (
01176 IN PLARGE_INTEGER OriginalTime,
01177 IN PLARGE_INTEGER DueTime,
01178 IN OUT PLARGE_INTEGER NewTime
01179 )
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203 {
01204
01205
01206
01207
01208
01209
01210
01211
if (OriginalTime->QuadPart >= 0) {
01212
return OriginalTime;
01213
01214 }
else {
01215 KiQueryInterruptTime(NewTime);
01216 NewTime->QuadPart -= DueTime->QuadPart;
01217
return NewTime;
01218 }
01219 }