RISC-V Assembly: This is fairly straightforward so I will skip it.
Backtrace: The calculation for this is given in the question itself but the difficult and most crucial aspect was to pay attention to how you manipulate memory/pointers. Lots of casting will be required.
Alarm: The code for this wasn’t a lot. The only hint I can give out is to focus on what functionality the trapframe accomplishes and see how you can leverage that. Also, there is a normal way to do this question and a lazy way, both should work. I came up with the normal way first and then came up with the lazy way. You can look at hhp3
’s videos on YouTube where he goes in depth into xv6, this was super helpful for me in understanding trapframe
and trampoline
and how they fit into trap handling. I had to change the FSSIZE parameter from 1000 to 10000 for one of the usertests to pass as well. My changes were working fine for alarmtests but had to make this change to make usertests pass.
One mistake I remember doing for the alarm
assignment was that somehow I had this notion in mind that I had to copy the alarm handler code into usertrap
and execute it there. But that is clearly not the case. If you read the question multiple times (as I did), we just need the kernel to go the alarm handler code, execute that code and return back.