CSE4001 Spring 2004 exam #3, open books, open notes. Name ________________ 1. Which of the following events will cause the processor to switch from user mode to kernel mode? Circle YES or NO (3 pts each). ANSWERS ------- A user process makes a system call YES Returning from a system call NO A timer interrupt YES An I/O device reads a memory buffer using DMA NO A segmentation fault YES 2. Why are disk blocks sometimes interleaved? (8 pts) ANSWER: To match disk rotation (latency) to I/O speed. 3. Suppose a disk block is 2K bytes (instead of 4K) and a pointer is 4 bytes. How many double indirect pointers would an inode need to support file sizes up to 4 GB? (7 pts) ANSWER: 8 (A block holds 512 pointers. 8 x 512 x 512 x 2K = 4 GB) 4. What causes a segmentation fault? (8 pts) ANSWER: accessing memory outside the segments allocated to the process. 5. What is the difference between a sleeping process and a suspended process? (8 pts) ANSWER: Sleeping = waiting on a system call, such as read(). Suspended = stopped (e.g. ^Z) and waiting for a SIGCONT signal. 6. What is the difference between batch and round-robin scheduling? Which does UNIX use? (8 pts) ANSWER: Batch = processes are run to completion before the next one starts. Round robin = processes are preempted after a time interval and placed on the end of the queue behind other processes of the same priority. UNIX uses round robin. 7. Explain how interactive processes are automatically given a higher priority than non-interactive. (8 pts) ANSWER: Processes that use less CPU are given higher priority. Interactive processes tend to use less CPU because they wait for input. 8. What feature of the MMU makes fork() more efficient by allowing both processes to share memory until one of them writes into it? (8 pts) ANSWER: The copy-on-write bit. Reads are allowed, but a write causes a page fault. The fault handler copies the page. 9. Circle one according to whether each action takes place in the MMU hardware, an interrupt handler (IH), or the page daemon (PD). (3 pts each) ANSWERS ------- Set page "referenced" bit. MMU Clear page "referenced" bit. PD Update the age of a page. PD Find the oldest page. PD Detect a page fault. MMU Translate logical to physical address. MMU Update segment registers. IH (the timer interrupt) Free a page in RAM. PD Copy a page to RAM. IH (the page fault interrupt) Copy a page to the swap file. PD