@@ -23,13 +23,12 @@ type ProcessorCore struct {
23
23
// within a physical package. For example, the core IDs for an Intel Core
24
24
// i7 are 0, 1, 2, 8, 9, and 10
25
25
ID int `json:"id"`
26
- // Index is the zero-based index of the core on the physical processor
27
- // package
28
- Index int `json:"index"`
29
26
// NumThreads is the number of hardware threads associated with the core
30
27
NumThreads uint32 `json:"total_threads"`
31
28
// LogicalProcessors is a slice of ints representing the logical processor
32
- // IDs assigned to any processing unit for the core
29
+ // IDs assigned to any processing unit for the core. These are sometimes
30
+ // called the "thread siblings". Logical processor IDs are the *zero-based*
31
+ // index of the processor on the host and are *not* related to the core ID.
33
32
LogicalProcessors []int `json:"logical_processors"`
34
33
}
35
34
@@ -38,7 +37,7 @@ type ProcessorCore struct {
38
37
func (c * ProcessorCore ) String () string {
39
38
return fmt .Sprintf (
40
39
"processor core #%d (%d threads), logical processors %v" ,
41
- c .Index ,
40
+ c .ID ,
42
41
c .NumThreads ,
43
42
c .LogicalProcessors ,
44
43
)
@@ -64,6 +63,16 @@ type Processor struct {
64
63
Cores []* ProcessorCore `json:"cores"`
65
64
}
66
65
66
+ // CoreByID returns the ProcessorCore having the supplied ID.
67
+ func (p * Processor ) CoreByID (coreID int ) * ProcessorCore {
68
+ for _ , core := range p .Cores {
69
+ if core .ID == coreID {
70
+ return core
71
+ }
72
+ }
73
+ return nil
74
+ }
75
+
67
76
// HasCapability returns true if the Processor has the supplied cpuid
68
77
// capability, false otherwise. Example of cpuid capabilities would be 'vmx' or
69
78
// 'sse4_2'. To see a list of potential cpuid capabilitiies, see the section on
0 commit comments