16# define InterlockedOrSetMember(Destination, SetMember) \
17 InterlockedOr64((PLONG64)Destination, SetMember);
19# define InterlockedOrSetMember(Destination, SetMember) \
20 InterlockedOr((PLONG)Destination, SetMember);
47 ASSERT(Prcb->DeferredReadyListHead.Next !=
NULL);
50 ListEntry = Prcb->DeferredReadyListHead.
Next;
51 Prcb->DeferredReadyListHead.
Next =
NULL;
58 ListEntry = ListEntry->
Next;
62 }
while (ListEntry !=
NULL);
65 ASSERT(Prcb->DeferredReadyListHead.Next ==
NULL);
74 KxQueueReadyThread(
Thread, Prcb);
103 OldPriority =
min(
Thread->AdjustIncrement + 1,
115 (
Thread->PriorityDecrement <= OldPriority));
147 if (!(
Thread->PriorityDecrement) && (
Thread->AdjustIncrement))
157 if (--
Thread->Quantum <= 0)
167 if (!(
Thread->PriorityDecrement) && !(
Thread->DisableBoost))
173 OldPriority =
Thread->BasePriority +
Thread->AdjustIncrement;
184 if (OldPriority >
Thread->Priority)
194 if (OldPriority > (
Thread->BasePriority +
205 (
Thread->PriorityDecrement <= OldPriority));
227 Preempted =
Thread->Preempted;
228 OldPriority =
Thread->Priority;
232 Thread->NextProcessor = 0;
260 if (OldPriority > NextThread->
Priority)
281 if (OldPriority > NextThread->
Priority)
337 Thread = Prcb->IdleThread;
341 Prcb->IdleSchedule =
TRUE;
368 NextThread = Prcb->NextThread;
372 Prcb->NextThread =
NULL;
373 Prcb->CurrentThread = NextThread;
383 Prcb->CurrentThread = NextThread;
392 NextThread = Prcb->IdleThread;
393 Prcb->CurrentThread = NextThread;
399 ASSERT(CurrentThread != Prcb->IdleThread);
403 WaitIrql = CurrentThread->WaitIrql;
409 WaitStatus = CurrentThread->WaitStatus;
439 else if (!
Thread->KernelStackResident)
475 if (--
Thread->Quantum <= 0)
531 if (!
Thread->ProcessReadyQueue)
587 OldPriority =
Thread->Priority;
627 OldPriority =
Thread->Priority;
642 RequestInterrupt =
TRUE;
648 if (RequestInterrupt)
668 DPRINT1(
"Deferred state not yet supported\n");
691 OldAffinity =
Thread->UserAffinity;
705 if (!
Thread->SystemAffinityActive)
709 DPRINT1(
"Affinity support disabled!\n");
732#define KiGetCurrentReadySummary() __readfsdword(FIELD_OFFSET(KIPCR, PrcbData.ReadySummary))
734#define KiGetCurrentReadySummary() __readgsdword(FIELD_OFFSET(KIPCR, Prcb.ReadySummary))
736#define KiGetCurrentReadySummary() KeGetCurrentPrcb()->ReadySummary
795 KxQueueReadyThread(
Thread, Prcb);
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define KeLowerIrql(oldIrql)
#define KeGetCurrentIrql()
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
KIRQL NTAPI KeRaiseIrqlToSynchLevel(VOID)
#define KeGetCurrentThread
#define MEMORY_PRIORITY_FOREGROUND
NTSYSAPI NTSTATUS WINAPI NtYieldExecution(void)
#define LOW_REALTIME_PRIORITY
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
FORCEINLINE PKTHREAD KiSelectReadyThread(IN KPRIORITY Priority, IN PKPRCB Prcb)
FORCEINLINE VOID KiSetThreadSwapBusy(IN PKTHREAD Thread)
FORCEINLINE VOID KiReleasePrcbLock(IN PKPRCB Prcb)
FORCEINLINE VOID KiAcquireThreadLock(IN PKTHREAD Thread)
FORCEINLINE VOID KiInsertDeferredReadyList(IN PKTHREAD Thread)
FORCEINLINE VOID KiReleaseThreadLock(IN PKTHREAD Thread)
FORCEINLINE VOID KiAcquirePrcbLock(IN PKPRCB Prcb)
FORCEINLINE SCHAR KiComputeNewPriority(IN PKTHREAD Thread, IN SCHAR Adjustment)
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
FORCEINLINE KAFFINITY AFFINITY_MASK(ULONG Index)
#define ASSERTMSG(msg, exp)
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
#define PRIORITY_MASK(Priority)
PKPRCB KiProcessorBlock[]
BOOLEAN FASTCALL KiSwapContext(IN KIRQL WaitIrql, IN PKTHREAD CurrentThread)
VOID FASTCALL KiIpiSend(KAFFINITY TargetSet, ULONG IpiRequest)
VOID FASTCALL KiExitDispatcher(KIRQL OldIrql)
_Out_ PKAPC_STATE ApcState
VOID NTAPI KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, IN PKEXCEPTION_FRAME ExceptionFrame, IN PKTRAP_FRAME TrapFrame)
#define STATUS_KERNEL_APC
#define STATUS_NO_YIELD_PERFORMED
ULONG PsPrioritySeparation
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
struct _KTHREAD * CurrentThread
struct _KTHREAD * NextThread
LIST_ENTRY DispatcherReadyListHead[32]
struct _SINGLE_LIST_ENTRY * Next
VOID NTAPI KiReadyThread(IN PKTHREAD Thread)
LONG_PTR FASTCALL KiSwapThread(IN PKTHREAD CurrentThread, IN PKPRCB Prcb)
PKTHREAD FASTCALL KiIdleSchedule(IN PKPRCB Prcb)
#define KiGetCurrentReadySummary()
VOID FASTCALL KiQueueReadyThread(IN PKTHREAD Thread, IN PKPRCB Prcb)
VOID NTAPI KiAdjustQuantumThread(IN PKTHREAD Thread)
KAFFINITY FASTCALL KiSetAffinityThread(IN PKTHREAD Thread, IN KAFFINITY Affinity)
VOID FASTCALL KiProcessDeferredReadyList(IN PKPRCB Prcb)
VOID FASTCALL KiDeferredReadyThread(IN PKTHREAD Thread)
KAFFINITY KiIdleSMTSummary
PKTHREAD FASTCALL KiSelectNextThread(IN PKPRCB Prcb)
VOID FASTCALL KiSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
#define InterlockedOrSetMember(Destination, SetMember)
#define CONTAINING_RECORD(address, type, field)
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql