# Project 0: Getting Real
## Preliminaries
If you have any preliminary comments on your submission, notes for the TAs, please
give them here.
Please cite any offline or online sources you consulted while preparing your
submission, other than the Pintos documentation, course text, lecture notes, and
course staff.
## Question Set 1
- Put the screenshot of Pintos running example next to this file in the directory
named `results`.
## Question Set 2
For context, see [Find the faulting Instruction](/spring2025/csc4103/projects/project0/faulting_instruction.html)
### Q1: What virtual address caused it to crash?
Why is the program not allowed to access this memory address at this point?
### Q2: What is the virtual address of the instruction that resulted in the crash?
### Q3: What is the name of the function the program was in when it crashed?
Copy the disassembled code for that function here, and identify the instruction at
which the program crashed.
Find the C code for the function you identified above and copy it here.
### Q4: Explain each instruction in the disassembled function in Q3
### Q5: Why did the instruction you identified in Q3 try to access memory at the virtual address you identified in Q1?
Please provide a high-level explanation, rather than simply mentioning register
values.
## Question Set 3
For context, see [Step through the Crash](/spring2025/csc4103/projects/project0/step_through_the_crash.html)
### Q1: Step into the `process_execute` function
What is the name and address of the thread running this function? What other threads
are present in PintOS at this time? Copy their `struct thread`s. (Hint: for the last
part, `dumplist &all_list thread allelem` may be useful.)
### Q2: What is the backtrace for the current thread?
Copy the backtrace from GDB as your answer and also copy down the line of C code
corresponding to each function call.
### Q3: Set a breakpoint at `start_process` and continue to that point
What is the name and address of the thread running this function? What other threads
are present in PintOS at this time? Copy their `struct thread`s.
### Q4: Where is the thread running `start_process` created? Copy down this line of code
### Q5: Print out the value of all members of the `if_` structure in the `start_process` function
### Q6: Why does the processor switch modes when executing the iret comand?
### Q7: print out the contents of registers after executing `iret`
How do these values compare to those when you printed out `if_`?
### Q8: Copy down the output of `btpagefault` after the page fault
## Question Set 4
For context, see [Debug](/spring2025/csc4103/projects/project0/debug.html)
### Q1: Modify the PintOS kernel so that `do-nothing` no longer crashes
Explain the change you made to PintOS and why it was necessary. After making this
change, the do-nothing test should pass.
### Q2: It is possible that your fix also works for the `stack-align-0` test, but there are solutions for do-nothing that do not
Take a look at the `stack-align-0` test. It behaves similarly to do-nothing, but it
returns the value of `%esp % 16`. Write down what this program should return (Hint:
this can be found in `stack-align-0.ck`) as well as why this is the case. Then modify
your fix if necessary so that both do-nothing and `stack-align-0` pass.
### Q3: Re-run GDB as before
Execute the `loadusersymbols` GDB command, set a breakpoint at start, and continue,
to skip directly to the beginning of userspace execution. Using the disassemble and
`stepi` commands, execute the `do-nothing` program instruction by instruction until
you reach the `int $0x30` instruction in `src/lib/user/syscall.c`. At this point,
print the top two words at the top of the stack by examining memory (Hint: `x/2xw
$esp`) and copy the output.
### Q4: The `int $0x30` instruction switches to kernel mode
... and pushes an interrupt stack frame onto the kernel stack for this process.
Continue stepping through instruction-by-instruction until you reach
`syscall_handler`. What are the values of `args[0]` and `args[1]`, and how do they
relate to your answer to the previous question?