gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 14:42:09 37 4
gpt4 key购买 nike

我希望我的 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/

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