This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Midterm Solutions CS 414 Operating Systems, Spring 2007 March 8 th , 2007 Prof. Hakim Weatherspoon Name: __________________________________NetId/Email:___________________________ Read all of the following information before starting the exam: Write down your name and NetId/email NOW. This is a closed book and notes examination. You have 90 minutes to answer as many questions as possible. The number in parentheses at the beginning of each question indicates the number of points given to the question; there are 100 points in all. You should read all of the questions before starting the exam, as some of the questions are substantially more time consuming. Write all of your answers directly on this paper. Make your answers as concise as possible . If a question is unclear, please simply answer the question and state your assumptions clearly. If you believe a question is open to interpretation, then please ask us about it! Good Luck!! Problem Possible Score 1 26 2 24 3 16 4 12 5 22 Total 100 CS 414 Spring 2007 Midterm Exam March 8, 2007 2/12 1. (26 points total) Short answer questions ( NO answer should be longer than two or three sentences ). a. (2 points) Name three ways in which the processor can transition form user mode to kernel mode? Can the user execute arbitrary code after transition? 1) The user process can execute a trap instruction (e.g. system call). A trap is known as a synchronous software interrupt. 2) The user process can cause an exception (divide by zero, access bad address, bad instruction, page fault, etc). 3) The processor can transition into kernel mode when receiving an interrupt. No, the user cannot execute arbitrary code because entry to kernel mode is through a restricted set of routines that ensure only the kernel is running, not the user process. b. (6 points) Threads i) (2 points) What needs to be saved and restored on a context switch between two threads in the same process? What if two are in different processes? Be brief and explicit. Need to save the registers, stack pointer, and program counter into the thread control block (TCB) of the thread that is no longer running. Need to reload the registers, stack pointer, and program counter from the TCB of the new thread. When the threads are from different processes, need to not only save and restore what was given above, but also need to load the pointer for the top-level page table of the new address space. (Note that this top-level page table pointer from the old process does not need to be saved since it does not change and is already contained in the process control block (PCB)). ii) (2 points) Why is switching threads less costly than switching processes? Less state needs to be saved and restored. Furthermore, switching between threads benefits from caching; whereas, switching between processes invalidates the cache and TLB....
View Full Document
This note was uploaded on 12/07/2011 for the course CS 4410 taught by Professor Vollset during the Spring '07 term at Cornell University (Engineering School).
- Spring '07
- Operating Systems