在每个页面错误上获取信号 [英] Get a signal on each page fault

查看:74
本文介绍了在每个页面错误上获取信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中设置一个信号处理程序,以便内核在处理页面错误陷阱时就发送一个信号.当然,我可以使用SIGSEGV信号处理程序,但是我真正感兴趣的是捕获写时复制时发生的页面错误.例如,在分叉(而不是exec)之后,如果原始进程尝试写入某个页面,则将出现页面错误.我想得到有关此类页面错误的通知.我该如何实现?

I want to set a signal handler in my application, so that the kernel sends a signal whenever it handles a page fault trap. Ofcourse I can use the SIGSEGV signal handler, but what I'm really interested in is to catch the page faults which occur on copy-on-write. For example after a fork (not followed by exec), the original process will get a page fault if it tries to write to some page. I want to get notified on such page faults. How can I achieve this?

推荐答案

页面错误是由do_page_fault()处理的中断

page faults are interrupts handled by do_page_fault()

http://www.stillhq.com/pdfdb/000446/data.pdf

信号还会生成一个中断.区别在于页面错误中断被引导至代码.解释了代码的作用. IMO,总是在中断处理程序中生成另一个中断是一个坏主意.

Signals also generate an interrupt. The difference is that the page fault interrupt is vectored to the code. There is an explanation of what the code does. IMO, always generating another interrupt in a an interrupt handler is a bad idea.

告诉我们:您要完成什么?不是你认为应该怎么做.

Tell us: What are you trying to accomplish? Not how you think it should be done.

这篇关于在每个页面错误上获取信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆