Assignment 3: v6 problem set
The following v6 review questions are divided up into sections based on our coverage during lecture. There are at total of 15 questions, each worth 4 points (for a total of 60 points for the assignment). Please provide your answers to them in the same order that they are listed below!
Please note that your answers should be grammatically correct and demonstrate to me that you understand the relevant concepts/code. Don't regurgitate Lions' commentary or source code comments.
Oh, and feel free to discuss these questions openly on Piazza!
Your solutions should be turned in via the assignments section on Blackboard as a PDF, Microsoft Word, or plain text document.
I. Kernel data structures
According to the comments that precede them, separate
proc(0358) anduser(0413) structures are allocated for every active process. If this is the case, explain the discrepancy in their manner of allocation at lines 0376 (for theprocarray) and 0459 (for theuvariable).The
procanduserstructures are said to cross-reference each other by way of component pointers. It should be noted, however, that the pointer stored in theprocstructure is in fact a physical block number, and not a virtual address. Why is this the case? How/When is this address used?
II. System startup
Explain the purpose of the computations performed in lines 0632-0634. What is the function of the following two lines of code?
In what process context are lines 0670-0672 executed, and what is their purpose?
While
proc[0]isn't technically created until line 1589, by this time we have already performed a subroutine jump (0669) and interrupts may also have occurred (e.g., the clock interrupt). What process's stack frame is being used to keep track of these actions?An important convention found in v6 is that the
u_procppointer in theuserstruct points back to its associatedprocarray entry. Explain why line 1891 results in an inconsistency, and why it is necessary.
III. Memory initialization / mapping
What is the resulting memory mapping by the end of line 0669? Does
proc 0’s user structure necessarily begin at the beginning of the 6th physical page? Why or why not?After reading through the
estabur(1650) andsureg(1739) functions, explain in your own words the purpose of theu.u_uisaandu.u_uisdarrays, and the responsibilities of the two functions that access them.
IV. Long / Short term scheduling
What is accomplished by the
savu/retupair found at the start of theswtchfunction (at lines 2189 and 2193)? Are they absolutely necessary for the kernel to operate correctly? What is their ultimate purpose? (Hint: look forward to the conditional at line 2218)One of the problems with priority based scheduling is starvation. A common approach to dealing with starvation is aging, where the priority of the current process is decreased over time. v6 takes this a step further, by also increasing the priority of non-running processes.
Identify the sections of v6 code that implement priority aging and briefly explain how they work.
During lecture we identified the
runrunflag as indicating that a higher priority process is ready to run; we confirmed its semantics by examining thesetrunfunction (2134). It is interesting to contrast the conditions checked at lines 2141 and 2165, however --- issetpribuggy? Explain.After reading through the
sched(long term scheduling / swapping) function on your own, explain when the '3 second / 2 second' rule is applied, and discuss the intuition behind it.
V. Interrupts / Traps
Why is it necessary at lines 756 and 777 for the
trapandcallfunctions to quickly save the value of thePSregister onto the stack? What is it used for (if anything), later on?What is the primary difference between the
aretu(line 734) andretu(line 740)? Under what conditions would a call toaretube required?In the
exitsystem call implementation (3219), what is the purpose of the loop starting at line 3250? In particular, what is achieved by the assignment at line 3252?