NdisGetCurrentProcessorCounts (Compact 2013)
3/26/2014
This function returns counts for the current processor that a driver can use to determine CPU usage for a particular time interval.
Syntax
VOID
NdisGetCurrentProcessorCounts(
OUT PULONG pIdleCount,
OUT PULONG pKernelAndUser,
OUT PULONG pIndex
);
Parameters
- pIdleCount
A pointer to a caller-supplied variable in which this function returns the cumulative idle time for the processor since the system was started.
- pKernelAndUser
A pointer to a caller-supplied variable in which this function returns the cumulative processing time (kernel-mode time plus user-mode time) for the processor since the system was started.
- pIndex
A pointer to a caller-supplied variable in which this function returns a zero-based index that identifies the processor within the device.
Return Value
None.
Remarks
NdisGetCurrentProcessorCounts returns idle and CPU-usage counts that the caller can use to determine CPU usage for the current processor. The CPU utilization value indicates how loaded the CPU was since the immediately previous call to this function. If the CPU was heavily loaded, such a driver can change how it handles certain operations to improve driver performance.
A driver might call NdisGetCurrentProcessorCounts periodically within a timer function. The driver can use the following calculation to determine the CPU usage for a multiple of the timer interval:
CpuUsage = 100-100*(Idle - Idle[n])/(KernelAndUser - KernelAndUser[n]);
where:
- CpuUsage is CPU usage as a percentage of the total interval time.
- Idle is the IdleCount value returned by the most recent call to NdisGetCurrentProcessorCounts.
- Idle[n] is an IdleCount value returned by a previous call, stored as the nth element in an array.
- KernelandUser is the KernelAndUser value returned by the most recent call to NdisGetCurrentProcessorCounts.
- KernelandUser[n] is the KernelandUser value returned by a previous call, stored as the nth element in an array.
For example, as the percentage of CPU usage trends higher, a miniport driver can disable interrupts on a network adapter and switch to polling the state of the network adapter. This strategy yields higher performance during periods of high network traffic by eliminating interrupt-processing overhead while the network adapter is generating many interrupts. Instead of using interrupts, such a miniport driver's NetTimerCallback function polls the network adapter and makes receive indications and completes send requests until network traffic declines again. When its periodic calls to NdisGetCurrentProcessorCounts indicate that CPU usage is trending lower again, such a driver would re-enable interrupts on the network adapter and cancel its timer.
Requirements
Header |
ndis.h |