Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
När operativsystemet anropar en registrerad återanropsfunktion skickar den en pekare till en DEVICE_INTERFACE_CHANGE_NOTIFICATION struktur i parametern NotificationStructure .
I följande kodexempel visas en implementering av en återanropsfunktion som bearbetar asynkrona drivrutinsmeddelanden för processorer:
// Asynchronous processor notification callback function
NTSTATUS
AsyncProcessorCallback(
IN PVOID NotificationStructure,
IN PVOID Context
)
{
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
ULONG ProcessorCount;
KAFFINITY ActiveProcessors;
Notification =
(PDEVICE_INTERFACE_CHANGE_NOTIFICATION)
NotificationStructure;
// Verify that this notification is about a processor
// that is being added to the hardware partition.
if (IsEqualGUID(
&Notification->Event,
&GUID_DEVICE_INTERFACE_ARRIVAL
))
{
// Get the current processor count and affinity
ProcessorCount =
KeQueryActiveProcessorCount(
&ActiveProcessors
);
// Adjust any resource allocations that are based
// on the number of processors.
...
// Adjust the assignment of resources that are
// assigned to specific processors.
...
// Begin scheduling any per processor threads
// on the new processor.
...
// Adjust the scheduling of DPCs and other threads
...
// Adjust any load balancing algorithms
...
}
// Always return success status
return STATUS_SUCCESS;
}
I följande kodexempel visas en implementering av en återanropsfunktion som bearbetar asynkrona drivrutinsmeddelanden för minne:
// Asynchronous memory notification callback function
NTSTATUS
AsyncMemoryCallback(
IN PVOID NotificationStructure,
IN PVOID Context
)
{
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
Notification =
(PDEVICE_INTERFACE_CHANGE_NOTIFICATION)
NotificationStructure;
// Verify that this notification is about memory
// that is being added to the hardware partition.
if (IsEqualGUID(
&Notification->Event,
&GUID_DEVICE_INTERFACE_ARRIVAL
))
{
// Increase the size of any memory buffers
// for optimal performance of the driver.
...
}
// Always return success status
return STATUS_SUCCESS;
}