Intel 64 and IA-32 Architectures Software Developers Manual Volume 3A, System Programming Guide, Part 1

Vol. 3A 7-47
MULTIPLE-PROCESSOR MANAGEMENT
ProcessorMask = 1;
CoreProcessorMask[0] = ProcessorMask;
For (ProcessorNum = 1; ProcessorNum < NumStartedLPs; ProcessorNum++) {
ProcessorMask << = 1;
For (i=0; i < CoreNum; i++) {
// we may be comparing bit-fields of logical processors residing in different
// packages, the code below assume package symmetry
If ((PackageID[ProcessorNum] | CoreID[ProcessorNum]) == CoreIDBucket[i]) {
CoreProcessorMask[i] |= ProcessorMask;
Break; // found in existing bucket, skip to next iteration
}
}
if (i == CoreNum) {
//Did not match any bucket, start new bucket
CoreIDBucket[i] = PackageID[ProcessorNum] | CoreID[ProcessorNum];
CoreProcessorMask[i] = ProcessorMask;
CoreNum++;
}
}
// CoreNum has the number of cores started in the OS
// CoreProcessorMask[] array has the processor set of each core
Other processor relationships such as processor mask of sibling cores can be
computed from set operations of the PackageProcessorMask[] and CoreProcessor-
Mask[].
The algorithm shown above can be applied to earlier generations of single-core
IA-32 processors that support Hyper-Threading Technology and in situations that
the deterministic cache parameter leaf is not supported (provided CPUID supports
initial APIC ID). This is handled by ensuring MaxCoresPerPackage() return 1 in
those situations.
7.11 MANAGEMENT OF IDLE AND BLOCKED CONDITIONS
When a logical processor in an MP system (including multi-core processor or proces-
sors supporting Hyper-Threading Technology) is idle (no work to do) or blocked (on a
lock or semaphore), additional management of the core execution engine resource
can be accomplished by using the HLT (halt), PAUSE, or the MONITOR/MWAIT
instructions.