1. PartB: Page Faults, Breakpoints Exceptions, and System Calls
1.1. 处理页错误
1.1.1. Exercise 5.
修改
trap_dispatch()将 page fault exceptions 分配到 page_fault_handler(). 记住你可以用make run-xormake run-x-nox是启动JOS执行特定的用户程序. For instance, make run-hello-nox runs the hello user program.
直接修改trap_dispatch函数,用switch case实现
// LAB 3: Your code here.
switch(tf->tf_trapno) {
case T_PGFLT: page_fault_handler(tf);break;
default: break;
}
faultread: OK (4.0s)
(Old jos.out.faultread failure log removed)
faultreadkernel: OK (3.7s)
(Old jos.out.faultreadkernel failure log removed)
faultwrite: OK (3.1s)
(Old jos.out.faultwrite failure log removed)
faultwritekernel: OK (3.3s)
(Old jos.out.faultwritekernel failure log removed)
1.2. The Breakpoint Exception(断点异常)
断点异常,中断向量3(T_BRKPT),通常用于允许调试器通过使用特殊的1字节int 3软件中断指令临时替换相关的程序指令,在程序代码中插入断点。
在JOS中,我们将稍微滥用此异常,将其转换为用户环境用于调用JOS内核监视器的原始伪系统调用。 如果我们将JOS内核监视器视为原始调试器,这种用法实际上是合适的。 例如,lib/panic.c中的panic()的用户模式实现在打印panic消息后执行int 3。
// Cause a breakpoint exception
while (1)
asm volatile("int3");
1.2.1. Exercise 6
Modify
trap_dispatch()to make breakpoint exceptions invoke the kernel monitor. You should now be able to get make grade to succeed on the breakpoint test.
同样在trap_dispatch中加入一个breakpiont的case就可以了。
case T_BRKPT:

这篇博客讨论了MIT6.828 LAB3的PartB,涉及页错误的处理,包括Exercise 5;断点异常,用于调用JOS内核监视器;系统调用的实现,通过中断向量进行;以及用户模式启动时的内存保护问题。在页错误处理中,解释了为何设置DPL会影响异常类型。同时,介绍了系统调用的过程,强调了内存保护的重要性,特别是内核面对用户指针时的挑战。
最低0.47元/天 解锁文章
354

被折叠的 条评论
为什么被折叠?



