免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3128 | 回复: 4
打印 上一主题 下一主题

请教Preemption:do_trap()如何保证是发给当前Process的? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-19 16:34 |只看该作者 |倒序浏览
在学习Understanding the Linux Kernel一书时,遇到如下的问题:

个人理解:
1. 当Exception发生时,硬件不会将IF清0,
2. 同时在entry.s中的Exception Handler的汇编中也并没有看到将Preemption Disable。
3.
下面一段出自该书的4.5.2. Entering and Leaving the Exception Handler Page 150页
As already explained, the names of the C functions that implement exception handlers always consist of the prefix do_ followed by the handler name. Most of these functions invoke the do_trap() function to store the hardware error code and the exception vector in the process descriptor of current, and then send a suitable signal to that process:

current->thread.error_code = error_code;
current->thread.trap_no = vector;
force_sig(sig_number, current);

小弟的疑问是:
如果在调用do_trap()之前发生了Preemption,那么do_trap()不就发送给其他Process signal了吗?

麻烦各位大大指点

论坛徽章:
0
2 [报告]
发表于 2011-03-19 20:50 |只看该作者
在学习Understanding the Linux Kernel一书时,遇到如下的问题:
如果在调用do_trap()之前发生了Preemption,那么do_trap()不就发送给其他Process signal了吗?
seurobot 发表于 2011-03-19 16:34


你理解的有问题,如果被抢占了,代码就不在do_trap了(尽管令一个可能也在这,但是栈不一样,tsk和current都不一样)
如果这个问题需要担心, 那任何需要current的地方都得禁止抢占了~

论坛徽章:
0
3 [报告]
发表于 2011-03-20 10:02 |只看该作者
本帖最后由 seurobot 于 2011-03-20 10:05 编辑

回复 2# flw2


    您的意思是说:Although after preemption, the current doesn't point to the process descriptor when the exception happens, but when do_trap() executes again, the current switch back to original value?

    谢谢指点。

论坛徽章:
0
4 [报告]
发表于 2011-03-20 11:10 |只看该作者
回复 3# seurobot


current永远标示当前进程,就像pthread_self代表当前线程一样
你可以看看current的代码,书上应该也说了,除非你是跳着看的

论坛徽章:
0
5 [报告]
发表于 2011-03-24 17:47 |只看该作者
回复 4# flw2


    已经理解了。非常感谢您的答复。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP