Which registers contain arguments to functions? For example, which register holds 13 in main's call to printf?
哪些寄存器包含了函数的参数?例如,在 main 调用 printf 时,哪个寄存器保存了数值 13?
a0-a7寄存器负责存储函数的参数,在main中,a2负责保存第三个参数13。
Where is the call to function f in the assembly code for main? Where is the call to g? (Hint: the compiler may inline functions.)
在 main 的汇编代码中,调用函数 f 的位置在哪里?调用 g 的位置又在哪里?(提示:编译器可能会内联函数。)
At what address is the function printf located?
函数 printf 位于哪个地址?
相对当前PC的地址为0x6b8。
What value is in the register ra just after the jalr to printf in main?
在 main 中用 jalr 到 printf 之后,寄存器 ra 中的值是什么?
指向下一条指令地址0x34。
Run the following code.
运行以下代码。
What is the output? Here's an ASCII table that maps bytes to characters.
输出结果是什么?这里有一个将字节映射为字符的 ASCII 表。
The output depends on that fact that the RISC-V is little-endian. If the RISC-V were instead big-endian what would you set i to in order to yield the same output? Would you need to change 57616 to a different value?
输出结果依赖于 RISC-V 是小端序的事实。如果 RISC-V 改为大端序,为了得到相同的输出,你需要将 i 设置为什么值?是否需要将 57616 改为不同的值?
i分解为0x00 64 6c 72,对应d l r,由于是小端序,所以应该是rld。57616的十六进制为0xe110。故整体输出为He110 World。
若为大端序,则i应改为0x726c6400,57616不用改。
In the following code, what is going to be printed after 'y='? (note: the answer is not a specific value.) Why does this happen?
在以下代码中, 'y=' 之后会打印什么内容?(注意:答案不是一个具体数值。)为什么会发生这种情况?
Implement a backtrace() function in kernel/printf.c. Insert a call to this function in sys_sleep, and then run bttest, which calls sys_sleep. Your output should be a list of return addresses with this form (but the numbers will likely be different):
在 kernel/printf.c 中实现一个 backtrace() 函数。在 sys_sleep 中插入对该函数的调用,然后运行 bttest (它会调用 sys_sleep )。你的输出应为一个返回地址列表,格式如下(但具体数字可能不同):
After bttest exit qemu. In a terminal window: run addr2line -e kernel/kernel (or riscv64-unknown-elf-addr2line -e kernel/kernel) and cut-and-paste the addresses from your backtrace, like this:
退出 qemu 后,在终端窗口中运行 addr2line -e kernel/kernel (或 riscv64-unknown-elf-addr2line -e kernel/kernel ),并剪切粘贴回溯中的地址,如下所示:
You should see something like this:
你应该会看到类似这样的输出:
In this exercise you'll add a feature to xv6 that periodically alerts a process as it uses CPU time. This might be useful for compute-bound processes that want to limit how much CPU time they chew up, or for processes that want to compute but also want to take some periodic action. More generally, you'll be implementing a primitive form of user-level interrupt/fault handlers; you could use something similar to handle page faults in the application, for example. Your solution is correct if it passes alarmtest and 'usertests -q'
在本练习中,您将为 xv6 添加一项功能,定期提醒进程其 CPU 使用时间。这对于希望限制 CPU 占用时间的计算密集型进程,或既需计算又想定期执行其他操作的进程非常有用。更广泛地说,您将实现一种用户级中断/故障处理程序的初级形式;例如,您可以使用类似机制处理应用程序中的页面错误。若您的解决方案能通过 alarmtest 和'usertests -q'测试,则视为正确。