Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

kernldat.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 kernldat.c 00008 00009 Abstract: 00010 00011 This module contains the declaration and allocation of kernel data 00012 structures. 00013 00014 Author: 00015 00016 David N. Cutler (davec) 12-Mar-1989 00017 00018 Revision History: 00019 00020 --*/ 00021 #include "ki.h" 00022 00023 // 00024 // The following data is read/write data that is grouped together for 00025 // performance. The layout of this data is important and must not be 00026 // changed. 00027 // 00028 // KiDispatcherReadyListHead - This is an array of type list entry. The 00029 // elements of the array are indexed by priority. Each element is a list 00030 // head for a set of threads that are in a ready state for the respective 00031 // priority. This array is used by the find next thread code to speed up 00032 // search for a ready thread when a thread becomes unrunnable. See also 00033 // KiReadySummary. 00034 // 00035 00036 LIST_ENTRY KiDispatcherReadyListHead[MAXIMUM_PRIORITY]; 00037 00038 // 00039 // KiIdleSummary - This is the set of processors that are idle. It is used by 00040 // the ready thread code to speed up the search for a thread to preempt 00041 // when a thread becomes runnable. 00042 // 00043 00044 KAFFINITY KiIdleSummary = 0; 00045 00046 // 00047 // KiReadySummary - This is the set of dispatcher ready queues that are not 00048 // empty. A member is set in this set for each priority that has one or 00049 // more entries in its respective dispatcher ready queues. 00050 // 00051 00052 ULONG KiReadySummary = 0; 00053 00054 // 00055 // KiTimerTableListHead - This is a array of list heads that anchor the 00056 // individual timer lists. 00057 // 00058 00059 LIST_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]; 00060 00061 // 00062 // KiSwapContextNotifyRoutine - This is the address of a callout routine 00063 // which is called at each context switch if the address is not NULL. 00064 // 00065 00066 PSWAP_CONTEXT_NOTIFY_ROUTINE KiSwapContextNotifyRoutine; 00067 00068 // 00069 // KiThreadSelectNotifyRoutine - This is the address of a callout routine 00070 // which is called when a thread is being selected for execution if 00071 // the address is not NULL. 00072 // 00073 00074 PTHREAD_SELECT_NOTIFY_ROUTINE KiThreadSelectNotifyRoutine; 00075 00076 // 00077 // KiTimeUpdateNotifyRoutine - This is the address of a callout routine 00078 // which is called when the runtime for a thread is updated if the 00079 // address is not NULL. 00080 // 00081 00082 PTIME_UPDATE_NOTIFY_ROUTINE KiTimeUpdateNotifyRoutine; 00083 00084 // 00085 // Public kernel data declaration and allocation. 00086 // 00087 // KeActiveProcessors - This is the set of processors that active in the 00088 // system. 00089 // 00090 00091 KAFFINITY KeActiveProcessors = 0; 00092 00093 // 00094 // KeBootTime - This is the absolute time when the system was booted. 00095 // 00096 00097 LARGE_INTEGER KeBootTime; 00098 00099 // 00100 // KeBootTimeBias - The time for which KeBootTime has ever been biased 00101 // 00102 00103 ULONGLONG KeBootTimeBias; 00104 00105 // 00106 // KeInterruptTimeBias - The time for which InterrupTime has ever been biased 00107 // 00108 00109 ULONGLONG KeInterruptTimeBias; 00110 00111 // 00112 // KeBugCheckCallbackListHead - This is the list head for registered 00113 // bug check callback routines. 00114 // 00115 00116 LIST_ENTRY KeBugCheckCallbackListHead; 00117 00118 // 00119 // KeBugCheckCallbackLock - This is the spin lock that guards the bug 00120 // check callback list. 00121 // 00122 00123 KSPIN_LOCK KeBugCheckCallbackLock; 00124 00125 // 00126 // KeDcacheFlushCount - This is the number of data cache flushes that have 00127 // been performed since the system was booted. 00128 // 00129 00130 ULONG KeDcacheFlushCount = 0; 00131 00132 // 00133 // KeIcacheFlushCount - This is the number of instruction cache flushes that 00134 // have been performed since the system was booted. 00135 // 00136 00137 ULONG KeIcacheFlushCount = 0; 00138 00139 // 00140 // KeGdiFlushUserBatch - This is the address of the GDI user batch flush 00141 // routine which is initialized when the win32k subsystem is loaded. 00142 // 00143 00144 PGDI_BATCHFLUSH_ROUTINE KeGdiFlushUserBatch; 00145 00146 // 00147 // KeLoaderBlock - This is a pointer to the loader parameter block which is 00148 // constructed by the OS Loader. 00149 // 00150 00151 PLOADER_PARAMETER_BLOCK KeLoaderBlock = NULL; 00152 00153 // 00154 // KeMinimumIncrement - This is the minimum time between clock interrupts 00155 // in 100ns units that is supported by the host HAL. 00156 // 00157 00158 ULONG KeMinimumIncrement; 00159 00160 // 00161 // KeNumberProcessors - This is the number of processors in the configuration. 00162 // If is used by the ready thread and spin lock code to determine if a 00163 // faster algorithm can be used for the case of a single processor system. 00164 // The value of this variable is set when processors are initialized. 00165 // 00166 00167 CCHAR KeNumberProcessors = 0; 00168 00169 // 00170 // KeRegisteredProcessors - This is the maxumum number of processors 00171 // which should utilized by the system. 00172 // 00173 00174 #if !defined(NT_UP) 00175 00176 #if DBG 00177 00178 ULONG KeRegisteredProcessors = 4; 00179 ULONG KeLicensedProcessors; 00180 00181 #else 00182 00183 ULONG KeRegisteredProcessors = 2; 00184 ULONG KeLicensedProcessors; 00185 00186 #endif 00187 00188 #endif 00189 00190 // 00191 // KeProcessorArchitecture - Architecture of all processors present in system. 00192 // See PROCESSOR_ARCHITECTURE_ defines in ntexapi.h 00193 // 00194 00195 USHORT KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_UNKNOWN; 00196 00197 // 00198 // KeProcessorLevel - Architectural specific processor level of all processors 00199 // present in system. 00200 // 00201 00202 USHORT KeProcessorLevel = 0; 00203 00204 // 00205 // KeProcessorRevision - Architectural specific processor revision number that is 00206 // the least common denominator of all processors present in system. 00207 // 00208 00209 USHORT KeProcessorRevision = 0; 00210 00211 // 00212 // KeFeatureBits - Architectural specific processor features present 00213 // on all processors. 00214 // 00215 00216 ULONG KeFeatureBits = 0; 00217 00218 // 00219 // KeServiceDescriptorTable - This is a table of descriptors for system 00220 // service providers. Each entry in the table describes the base 00221 // address of the dispatch table and the number of services provided. 00222 // 00223 00224 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[NUMBER_SERVICE_TABLES]; 00225 KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[NUMBER_SERVICE_TABLES]; 00226 00227 // 00228 // KeThreadSwitchCounters - These counters record the number of times a 00229 // thread can be scheduled on the current processor, any processor, 00230 // or the last processor it ran on. 00231 // 00232 00233 KTHREAD_SWITCH_COUNTERS KeThreadSwitchCounters; 00234 00235 // 00236 // KeTimeIncrement - This is the nominal number of 100ns units that are to 00237 // be added to the system time at each interval timer interupt. This 00238 // value is set by the HAL and is used to compute the dure time for 00239 // timer table entries. 00240 // 00241 00242 ULONG KeTimeIncrement; 00243 00244 // 00245 // KeTimeSynchronization - This variable controls whether time synchronization 00246 // is performed using the realtime clock (TRUE) or whether it is under the 00247 // control of a service (FALSE). 00248 // 00249 00250 BOOLEAN KeTimeSynchronization = TRUE; 00251 00252 // 00253 // KeUserApcDispatcher - This is the address of the user mode APC dispatch 00254 // code. This address is looked up in NTDLL.DLL during initialization 00255 // of the system. 00256 // 00257 00258 PVOID KeUserApcDispatcher; 00259 00260 // 00261 // KeUserCallbackDispatcher - This is the address of the user mode callback 00262 // dispatch code. This address is looked up in NTDLL.DLL during 00263 // initialization of the system. 00264 // 00265 00266 PVOID KeUserCallbackDispatcher; 00267 00268 // 00269 // KeUserExceptionDispatcher - This is the address of the user mode exception 00270 // dispatch code. This address is looked up in NTDLL.DLL during system 00271 // initialization. 00272 // 00273 00274 PVOID KeUserExceptionDispatcher; 00275 00276 // 00277 // KeRaiseUserExceptionDispatcher - This is the address of the raise user 00278 // mode exception dispatch code. This address is looked up in NTDLL.DLL 00279 // during system initialization. 00280 // 00281 00282 PVOID KeRaiseUserExceptionDispatcher; 00283 00284 // 00285 // Private kernel data declaration and allocation. 00286 // 00287 // KiBugCodeMessages - Address of where the BugCode messages can be found. 00288 // 00289 00290 #if DEVL 00291 00292 PMESSAGE_RESOURCE_DATA KiBugCodeMessages = NULL; 00293 00294 #endif 00295 00296 // 00297 // KiDmaIoCoherency - This determines whether the host platform supports 00298 // coherent DMA I/O. 00299 // 00300 00301 ULONG KiDmaIoCoherency; 00302 00303 // 00304 // KiMaximumSearchCount - this is the maximum number of timers entries that 00305 // have had to be examined to insert in the timer tree. 00306 // 00307 00308 ULONG KiMaximumSearchCount = 0; 00309 00310 // 00311 // KiDebugRoutine - This is the address of the kernel debugger. Initially 00312 // this is filled with the address of a routine that just returns. If 00313 // the system debugger is present in the system, then it sets this 00314 // location to the address of the systemn debugger's routine. 00315 // 00316 00317 PKDEBUG_ROUTINE KiDebugRoutine; 00318 00319 // 00320 // KiDebugSwitchRoutine - This is the address of the kernel debuggers 00321 // processor switch routine. This is used on an MP system to 00322 // switch host processors while debugging. 00323 // 00324 00325 PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine; 00326 00327 // 00328 // KiDispatcherLock - This is the spin lock that guards the dispatcher 00329 // database. 00330 // 00331 00332 extern KSPIN_LOCK KiDispatcherLock; 00333 00334 CCHAR KiFindFirstSetRight[256] = { 00335 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00336 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00337 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00338 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00339 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00340 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00341 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00342 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00343 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00344 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00345 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00346 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 00347 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 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- This is the spin lock that guards the freezing 00372 // of execution. 00373 // 00374 00375 extern KSPIN_LOCK KiFreezeExecutionLock; 00376 00377 // 00378 // KiFreezeLockBackup - For debug builds only. Allows kernel debugger to 00379 // be entered even FreezeExecutionLock is jammed. 00380 // 00381 00382 extern KSPIN_LOCK KiFreezeLockBackup; 00383 00384 // 00385 // KiFreezeFlag - For debug builds only. Flags to track and signal non- 00386 // normal freezelock conditions. 00387 // 00388 00389 ULONG KiFreezeFlag; 00390 00391 // 00392 // KiSuspenState - Flag to track suspend/resume state of processors. 00393 // 00394 00395 volatile ULONG KiSuspendState; 00396 00397 // 00398 // KiFindLeftNibbleBitTable - This a table that is used to find the left most bit in 00399 // a 4-bit nibble. 00400 // 00401 00402 UCHAR KiFindLeftNibbleBitTable[] = {0, 0, 1, 1, 2, 2, 2, 2, 00403 3, 3, 3, 3, 3, 3, 3, 3}; 00404 00405 // 00406 // KiProcessorBlock - This is an array of pointers to processor control blocks. 00407 // The elements of the array are indexed by processor number. Each element 00408 // is a pointer to the processor control block for one of the processors 00409 // in the configuration. This array is used by various sections of code 00410 // that need to effect the execution of another processor. 00411 // 00412 00413 PKPRCB KiProcessorBlock[MAXIMUM_PROCESSORS]; 00414 00415 // 00416 // KiSwapEvent - This is the event that is used to wake up the balance set 00417 // thread to inswap processes, outswap processes, and to inswap kernel 00418 // stacks. 00419 // 00420 00421 KEVENT KiSwapEvent; 00422 00423 // 00424 // KiProcessInSwapListHead - This is the list of processes that are waiting 00425 // to be inswapped. 00426 // 00427 00428 LIST_ENTRY KiProcessInSwapListHead; 00429 00430 // 00431 // KiProcessOutSwapListHead - This is the list of processes that are waiting 00432 // to be outswapped. 00433 // 00434 00435 LIST_ENTRY KiProcessOutSwapListHead; 00436 00437 // 00438 // KiStackInSwapListHead - This is the list of threads that are waiting 00439 // to get their stack inswapped before they can run. Threads are 00440 // inserted in this list in ready thread and removed by the balance 00441 // set thread. 00442 // 00443 00444 LIST_ENTRY KiStackInSwapListHead; 00445 00446 // 00447 // KiProfileSourceListHead - The list of profile sources that are currently 00448 // active. 00449 // 00450 00451 LIST_ENTRY KiProfileSourceListHead; 00452 00453 // 00454 // KiProfileAlignmentFixup - Indicates whether alignment fixup profiling 00455 // is active. 00456 // 00457 00458 BOOLEAN KiProfileAlignmentFixup; 00459 00460 // 00461 // KiProfileAlignmentFixupInterval - Indicates the current alignment fixup 00462 // profiling interval. 00463 // 00464 00465 ULONG KiProfileAlignmentFixupInterval; 00466 00467 // 00468 // KiProfileAlignmentFixupCount - Indicates the current alignment fixup 00469 // count. 00470 // 00471 00472 ULONG KiProfileAlignmentFixupCount; 00473 00474 // 00475 // KiProfileInterval - The profile interval in 100ns units. 00476 // 00477 00478 ULONG KiProfileInterval = DEFAULT_PROFILE_INTERVAL; 00479 00480 // 00481 // KiProfileListHead - This is the list head for the profile list. 00482 // 00483 00484 LIST_ENTRY KiProfileListHead; 00485 00486 // 00487 // KiProfileLock - This is the spin lock that guards the profile list. 00488 // 00489 00490 extern KSPIN_LOCK KiProfileLock; 00491 00492 // 00493 // KiTimerExpireDpc - This is the Deferred Procedure Call (DPC) object that 00494 // is used to process the timer queue when a timer has expired. 00495 // 00496 00497 KDPC KiTimerExpireDpc; 00498 00499 // 00500 // KiTimeIncrementReciprocal - This is the reciprocal fraction of the time 00501 // increment value that is specified by the HAL when the system is 00502 // booted. 00503 // 00504 00505 LARGE_INTEGER KiTimeIncrementReciprocal; 00506 00507 // 00508 // KiTimeIncrementShiftCount - This is the shift count that corresponds to 00509 // the time increment reciprocal value. 00510 // 00511 00512 CCHAR KiTimeIncrementShiftCount; 00513 00514 // 00515 // KiWaitInListHead - This is a list of threads that are waiting with a 00516 // resident kernel stack. 00517 // 00518 00519 LIST_ENTRY KiWaitInListHead; 00520 00521 // 00522 // KiWaitOutListHead - This is a list of threads that are either waiting 00523 // with a kernel stack that is nonresident or are not elligible to 00524 // have their stack swapped. 00525 // 00526 00527 LIST_ENTRY KiWaitOutListHead; 00528 00529 // 00530 // Private kernel data declaration and allocation. 00531 // 00532 // 00533 // KiIpiCounts - Instrumentation counters for IPI requests. 00534 // Each processor has it's own set. Intstrumentation build only. 00535 // 00536 00537 #if NT_INST 00538 00539 KIPI_COUNTS KiIpiCounts[MAXIMUM_PROCESSORS]; 00540 00541 #endif // NT_INST 00542 00543 // 00544 // KxUnexpectedInterrupt - This is the interrupt object that is used to 00545 // populate the interrupt vector table for interrupt that are not 00546 // connected to any interrupt. 00547 // 00548 00549 #if defined(_ALPHA_) || defined(_IA64_) 00550 00551 KINTERRUPT KxUnexpectedInterrupt; 00552 00553 #endif 00554 00555 // 00556 // Performance data declaration and allocation. 00557 // 00558 // KiFlushSingleCallData - This is the call performance data for the kernel 00559 // flush single TB function. 00560 // 00561 00562 #if defined(_COLLECT_FLUSH_SINGLE_CALLDATA_) 00563 00564 CALL_PERFORMANCE_DATA KiFlushSingleCallData; 00565 00566 #endif 00567 00568 // 00569 // KiSetEventCallData - This is the call performance data for the kernel 00570 // set event function. 00571 // 00572 00573 #if defined(_COLLECT_SET_EVENT_CALLDATA_) 00574 00575 CALL_PERFORMANCE_DATA KiSetEventCallData; 00576 00577 #endif 00578 00579 // 00580 // KiWaitSingleCallData - This is the call performance data for the kernel 00581 // wait for single object function. 00582 // 00583 00584 #if defined(_COLLECT_WAIT_SINGLE_CALLDATA_) 00585 00586 CALL_PERFORMANCE_DATA KiWaitSingleCallData; 00587 00588 #endif 00589 00590 // 00591 // KiEnableTimerWatchdog - Flag to enable/disable timer latency watchdog. 00592 // 00593 00594 #if (DBG) 00595 ULONG KiEnableTimerWatchdog = 1; 00596 #else 00597 ULONG KiEnableTimerWatchdog = 0; 00598 #endif

Generated on Sat May 15 19:40:35 2004 for test by doxygen 1.3.7