q1_fall04_sol

Q1_fall04_sol - Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.828 Operating System Engineering

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.828 Operating System Engineering: Fall 2004 Quiz I Solutions All problems are open-ended questions. In order to receive credit you must answer the question as precisely as possible. You have 80 minutes to answer this quiz. Write your name on this cover sheet AND at the bottom of each page of this booklet. Some questions may be much harder than others. Read them all through first and attack them in the order that allows you to make the most progress. If you find a question ambiguous, be sure to write down any assumptions you make. Be neat. If we can’t understand your answer, we can’t give you credit! THIS IS AN OPEN BOOK, OPEN NOTES QUIZ. 1 (xx/40) 2 (xx/25) 3 (xx/25) 4 (xx/10) Total (xx/100) Name:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6.828 FALL 2004, Quiz 1 Solutions Page 2 of 13 Virtual memory 1. [5 points]: The PDP-11 uses two bits in the Processor Status Word (PSW) to determine whether it is currently running in kernel or user mode. Which bits in which register on the x86 determine whether the processor is running in kernel or user mode, and what x86 instruction does the JOS kernel use to enter user mode? (Explain briefly) The low two bits of the Code Segment (CS) register represent the x86 processor’s Cur- rent Privilege Level (CPL): 0 is the most privileged level (“kernel mode”), 3 is the least privileged level (“user mode”), and the other two values represent intermediate privilege levels that most operating systems do not use. The JOS kernel uses the IRET instruction to enter (or “return to”) user mode. IRET loads the EIP, CS, EFLAGS, ESP, and SS registers from the kernel stack, in effect changing to the user privilege level, switching to the user’s stack, and jumping to the appropriate user code all in one atomic processor operation. 2. [5 points]: The v6 kernel must copy values from user space with the special instruction mfpi (push onto the current stack the value of the designated word in the “previous” address space). What instructions does the JOS kernel use to access user-level values? (Explain briefly) No special instructions are required for the JOS kernel to access the user address space, because JOS maps the kernel’s private virtual address region identically into every user en- vironment’s virtual address space, protecting the kernel-private mappings from user-mode access via the PTE U bit in the appropriate page directory and page table entries. When- ever the kernel is executing in the context of (on behalf of) a particular user environment whose address space is active (loaded into the processor’s CR3 register), as long as the kernel takes appropriate precautions to protect itself from invalid pointers passed by the user, the kernel can access the user’s address space with ordinary instructions such as MOV , using the same user virtual addresses that the user environment itself would use to access its own memory. Name:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/29/2010 for the course 6 828 taught by Professor Guy during the Spring '08 term at MIT.

Page1 / 13

Q1_fall04_sol - Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.828 Operating System Engineering

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online