CS350 Midterm: S12-midterm-sol.pdf

41 views14 pages
8 Oct 2014
Course
Professor

Document Summary

Student #: __ __ __ __ __ __ __ __ Make sure you answer it at the end: relax! Question 1 [10 marks] (a) [3 marks] )n os/(cid:883)(cid:888)(cid:883) there is a struct thread to represent a thread context and a struct trapframe to represent a trap frame. Describe something that is contained in both structures, and then for each of the structures describe something that it contains that the other does not. Briefly explain why each of the (cid:885) things you describe appears where it does. Almost all registers are stored in a trap frame when a trap occurs (interrupt/syscall/exception), but only a subset are backed up when a thread context switch occurs. So (for example) s1 would be in both, but temp register t0 would only be in the trapframe. Within v(), interrupts are disabled so it cannot be. Briefly describe a situation where you would prefer a lock and a situation where you would prefer a binary semaphore.