Edit

Share via


PsQueryProcessAvailableCpus function (wdm.h)

The PsQueryProcessAvailableCpus function queries the set of CPUs that are available for a given process to run on.

Syntax

NTSTATUS PsQueryProcessAvailableCpus(
  [in]           PEPROCESS     Process,
  [in, out]      PKAFFINITY_EX Affinity,
  [in, optional] PULONG64      ObservedSequenceNumber,
  [out]          PULONG64      SequenceNumber
);

Parameters

[in] Process

Pointer to a process (PEPROCESS).

[in, out] Affinity

Pointer to an extended affinity object (PKAFFINITY_EX) that will receive the set of available CPUs for the process.

[in, optional] ObservedSequenceNumber

Optionally supplies a pointer to the most recent sequence number observed by the caller through a previous call to this routine. If this sequence number matches the current sequence number, the routine returns STATUS_NO_WORK_DONE and doesn't write to the affinity buffer.

[out] SequenceNumber

Pointer to a buffer that will receive the current sequence number for the available CPUs to the given process.

Return value

PsQueryProcessAvailableCpus returns one of the following NTSTATUS values:

Return code Description
STATUS_SUCCESS The query was completed successfully.
STATUS_INVALID_PARAMETER Any of the required buffers is NULL.
STATUS_NO_WORK_DONE The given sequence number matches the current sequence number and no query was performed.
STATUS_BUFFER_TOO_SMALL The given affinity buffer is too small.

Remarks

This routine can be called at IRQL from PASSIVE_LEVEL to DISPATCH_LEVEL.

The affinity buffer must be large enough to accommodate the active processor group count. Use KeQueryActiveGroupCount to determine the required size.

The sequence number allows callers to optimize repeated queries by checking if the CPU availability has changed since the last call.

Requirements

Requirement Value
Header wdm.h
IRQL PASSIVE_LEVEL to DISPATCH_LEVEL

See also

PsQueryProcessAvailableCpusCount

PsQuerySystemAvailableCpus

KeQueryActiveGroupCount