gpt4 book ai didi

objective-c - 每个 CPU 内核处于 C0 电源状态的时间

转载 作者:太空狗 更新时间:2023-10-30 03:29:17 25 4
gpt4 key购买 nike

任何帮助弄清楚如何做到这一点的帮助都会很棒:每个 CPU 内核在过去一秒内花费了多少时间在 C0 电源状态。

这是一个 mac 应用程序,因此需要 Objective-C、cocoa 和 c。

最佳答案

OS X 没有任何公开 CPU c 状态的 API。但是,您似乎可以使用英特尔 CPU 上的 MWAIT/MONITOR 指令来执行此操作。 Intel 在引用手册的第 14.4 节中提到您可以使用此技术跟踪 C 状态驻留:

Software should use CPUID to discover if a target processor supports the enumeration of MWAIT extensions. If CPUID.05H.ECX[Bit 0] = 1, the target processor supports MWAIT extensions and their enumeration (see Chapter 3, “Instruction Set Reference, A-M,” of Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A).

If CPUID.05H.ECX[Bit 1] = 1, the target processor supports using interrupts as break-events for MWAIT, even when interrupts are disabled. Use this feature to measure C-state residency as follows:

  • Software can write to bit 0 in the MWAIT Extensions register (ECX) when issuing an MWAIT to enter into a processor-specific C-state or sub C-state.
  • When a processor comes out of an inactive C-state or sub C-state, software can read a timestamp before an interrupt service routine (ISR) is potentially executed.
  • 您可以在同一手册中找到有关 MWAIT 指令的更多信息。祝你好运!

    Intel's Reference Manual

    关于objective-c - 每个 CPU 内核处于 C0 电源状态的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3512611/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com