Intel ARCHITECTURE IA-32 User Manual Page 397

  • Download
  • Add to my manuals
  • Print
  • Page
    / 568
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 396
Multi-Core and Hyper-Threading Technology 7
7-51
Affinity masks can be used to optimize shared multi-threading
resources.
Example 7-11 Assembling 3-level IDs, Affinity Masks for Each Logical
Processor
// The BIOS and/or OS may limit the number of logical processors
// available to applications after system boot.
// The below algorithm will compute topology for the logical processors
// visible to the thread that is computing it.
// Extract the 3-levels of IDs on every processor.
// SystemAffinity is a bitmask of all the processors started by the OS.
// Use OS specific APIs to obtain it.
// ThreadAffinityMask is used to affinitize the topology enumeration
// thread to each processor using OS specific APIs.
// Allocate per processor arrays to store the Package_ID, Core_ID and
// SMT_ID for every started processor.
typedef struct {
AFFINITYMASK affinity_mask; // 8 byte in 64-bit mode,
// 4 byte otherwise.
unsigned char smt;
; unsigned char core;
unsigned char pkg;
unsigned char initialAPIC_ID;
} APIC_MAP_T;
APIC_MAP_T apic_conf[64];
ThreadAffinityMask = 1;
ProcessorNum = 0;
while (ThreadAffinityMask != 0 && ThreadAffinityMask <=
SystemAffinity) {
// Check to make sure we can utilize this processor first.
Page view 396
1 2 ... 392 393 394 395 396 397 398 399 400 401 402 ... 567 568

Comments to this Manuals

No comments