# 练习

## 练习1：描述处理中断异常的流程

像LAB0.5里的执行流一样描述ucore是如何处理中断异常的。从异常的产生开始。

## 练习2：对于任何中断，都需要保存所有寄存器吗？为什么？

## 练习3：触发、捕获、处理异常

编程：在任意位置触发一条非法指令异常（如：mret），在 `kern/trap/trap.c`的异常处理函数中捕获，并对其进行处理，简单输出异常类型和指令即可。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nankai.gitbook.io/ucore-os-on-risc-v64/lab1/lian-xi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
