windows - 在 Windows 上以编程方式读取程序的页面错误计数

标签 windows winapi etw

我希望我的 Windows C++ 程序能够读取它所导致的硬页面错误的数量。该程序未以管理员身份运行。 编辑添加:明确地说,我对整个系统的页面错误总数不感兴趣。

看起来 ETW 可能会为此导出计数器,但我在弄清楚 API 时遇到了很多困难,而且与管理员相比,普通用户可以访问哪些内容尚不清楚。

有没有人有这个功能的例子?还是在 Windows 上根本不可能?

(OT,但是这在 *nix 上容易得多吗?gerusage(),你就完成了。)

最佳答案

afai 可以说唯一的方法是使用 ETW(Windows 事件跟踪)来监视内核硬页面错误。事件负载有一个线程 ID,您可以将其与现有进程相关联(顺便说一句,这将是非常重要的)以生成每个进程的运行计数。我看不到任何方法可以获取每个进程的历史信息。

我可以向你保证这是一个难题,因为 Process Explorer在其每个进程显示中仅支持页面错误(软或硬)。

http://msdn.microsoft.com/en-us/magazine/ee412263.aspx

A page fault occurs when a sought-out page table entry is invalid. If the requested page needs to be brought in from disk, it is called a hard page fault (a very expensive operation), and all other types are considered soft page faults (a less expensive operation). A Page Fault event payload contains the virtual memory address for which a page fault happened and the instruction pointer that caused it. A hard page fault requires disk access to occur, which could be the first access to contents in a file or accesses to memory blocks that were paged out. Enabling Page Fault events causes a hard page fault to be logged as a page fault with a type Hard Page Fault. However, a hard fault typically has a considerably larger impact on performance, so a separate event is available just for a hard fault that can be enabled independently. A Hard Fault event payload has more data, such as file key, offset and thread ID, compared with a Page Fault event.

关于windows - 在 Windows 上以编程方式读取程序的页面错误计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6416005/

相关文章:

windows - 如何在 NVIDIA P100 上启用 WDDM?

c++ - 32 位 x86 上的 64 位 int 算术(来自 c )

c++ - 以编程方式设置全局环境变量

windows - 在 Go 和 Windows API 中处理未确定大小的数组

azure-service-fabric - Visual Studio 中的诊断事件查看器 - 如何配置

c++ - 如何在 Windows 上将 bcrypt_gensalt 与/dev/urandom 一起使用?

windows - 尝试使用图形魔法绘制文本或图像时出现错误 "non-conforming drawing primitive"

c - 在 Windows 中用 C 守护进程

c++ - Windows 上的蓝牙低功耗低速率?

windows - 使用 WPP 跟踪到多个 ETW 提供程序