LAB3_User-Level Environments_PartB Page Faults, Breakpoints Exceptions, and System Calls

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-xor make 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:
			monitor(tf);
			break;

1.2.2. Questions<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值