Share via


NdisGetCurrentProcessorCounts (NDIS 5.1) function

Note   NDIS 5. x has been deprecated and is superseded by NDIS 6. x. For new NDIS driver development, see Network Drivers Starting with Windows Vista. For information about porting NDIS 5. x drivers to NDIS 6. x, see Porting NDIS 5.x Drivers to NDIS 6.0.

NdisGetCurrentProcessorCounts 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 [out]
    Pointer to a caller-supplied variable in which this function returns the cumulative idle time for the processor since the system was booted.

  • pKernelAndUser [out]
    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 booted.

  • pIndex [out]
    Pointer to a caller-supplied variable in which this function returns a zero-based index that identifies the processor within the computer.

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 preceding 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 the NIC and switch to polling the state of its NIC. This strategy yields higher performance during periods of high network traffic by eliminating interrupt-processing overhead while the NIC is generating many interrupts. Instead, such a NIC driver's polling MiniportTimer function makes indications and completes sends 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 its NIC and cancel its polling MiniportTimer function.

Requirements

Target platform

Universal

Version

See NdisGetCurrentProcessorCounts.

Header

Ndis.h (include Ndis.h)

Library

Ndis.lib

IRQL

<= DISPATCH_LEVEL

See also

MiniportDisableInterrupt

MiniportHandleInterrupt

MiniportISR

MiniportTimer

NdisGetCurrentProcessorCpuUsage

NdisMCancelTimer

NdisMSetPeriodicTimer

 

 

Send comments about this topic to Microsoft