Chinaunix

标题: 异常或者自陷与进程context [打印本页]

作者: yypzgmmm    时间: 2009-02-11 13:53
标题: 异常或者自陷与进程context
刚才看到一篇文章中有这么一段话"中断或者异常或者自陷等,从概念上说,此时没有进程context,不能进行context switch。"  中断是异步的,没有进程context可以理解,异常和自陷是同步的,应该有进程context。 没理解,请大家帮我分析分析!
作者: scutan    时间: 2009-02-11 15:09
异常处理和自陷的时候是会发生进程切换的.
作者: xpl    时间: 2009-02-11 15:20
原帖由 scutan 于 2009-2-11 15:09 发表
异常处理和自陷的时候是会发生进程切换的.


异常处理的时候是不允许发生进程切换的。
作者: scutan    时间: 2009-02-11 16:01
原帖由 xpl 于 2009-2-11 15:20 发表


异常处理的时候是不允许发生进程切换的。


经常碰到的缺页异常, 在执行时, 内核就可以挂起当前进程, 而切换到另外的进程去.
作者: xpl    时间: 2009-02-11 17:00
原帖由 scutan 于 2009-2-11 16:01 发表


经常碰到的缺页异常, 在执行时, 内核就可以挂起当前进程, 而切换到另外的进程去.


你能确定是“切换到另外的进程”吗?
作者: scutan    时间: 2009-02-11 17:56
原帖由 xpl 于 2009-2-11 17:00 发表


你能确定是“切换到另外的进程”吗?


Assuming that the kernel is bug free, most exceptions can occur only while the CPU is in User Mode. Indeed, they are either caused by programming errors or triggered by debuggers. However, the "Page Fault " exception may occur in Kernel Mode. This happens when the process attempts to address a page that belongs to its address space but is not currently in RAM. While handling such an exception, the kernel may suspend the current process and replace it with another one until the requested page is available. The kernel control path that handles the "Page Fault" exception resumes execution as soon as the process gets the processor again.


另外, 系统调用也是一种异常, 在执行它的时候也可以发生进程切换的啊.

另外在ULK第五章第一节也有一句话:
The above rules tell us that the kernel can be preempted only when it is executing an exception handler (in particular a system call) and the kernel preemption has not been explicitly disabled.
作者: xpl    时间: 2009-02-12 11:46
原帖由 scutan 于 2009-2-11 17:56 发表


Assuming that the kernel is bug free, most exceptions can occur only while the CPU is in User Mode. Indeed, they are either caused by programming errors or triggered by debuggers. However, th ...


Sure, I made a mistake.

Exception is synchronization.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2