Operating Systems Clicker Questions Kevin Webb & Cynthia Taylor The operating system kernel… A. Executes as a process B. Is always executing, in support of other processes C. Should execute as little as possible D. More than one of the above Why shouldn’t processes control context switching? A. It would cause too much overhead B. They could refuse to give up the CPU C. They don’t have enough information about other processes 3 Which CPU scheduling policy is the best? A. Processes keep CPU until done (maximize throughput) B. Processes use a fraction of CPU and pass it on (ensure fairness) C. Processes receive CPU in proportion to their priority or what they pay (prioritize importance) D. Other (explain) Which is true of round-robin schedules relative to first-come first-served. A. Round-robin requires knowledge of process run times. B. Round-robin schedules have lower average turnaround times. C. Round-robin schedules have higher average turnaround times. D. Round-robin has higher overhead. E. More than one of these Multi-level feedback queues will naturally prioritize… A. Compute-bound processes B. I/O-bound processes C. Long-running processes D. Short processes Which component of a process might we replicate to take advantage of multiple CPUs? A. The address space (memory) B. OS resources (open files, etc.) C. Execution state (PC, SP, registers, etc.) D. More than one of these E. Some other component(s) If you call thread_create() on a modern OS (Linux/Mac/Windows), which type of thread would you expect to receive? (Why? Which would you pick?) A. Kernel thread B. User thread C. Some other sort of thread For processes (or threads) to communicate, we must have: A. a data transfer mechanism B. a synchronization mechanism C. either synchronization or data transfer D. both synchronization and data transfer Suppose we’re using message passing, will this code operate correctly? /* NO SHARED MEMORY */ Producer int item; Consumer int item; while (TRUE) { while (TRUE) { item = Produce (); receive (Producer, &item); send (Consumer, &item); Consume (item); } } A. No, there is a race condition. B. No, we need to protect item. C. Yes, this code is correct. This code is correct and relatively simple. Why don’t we always just use message passing (vs semaphores)? /* NO SHARED MEMORY */ Producer int item; Consumer int item; while (TRUE) { while (TRUE) { item = Produce (); receive (Producer, &item); send (Consumer, &item); Consume (item); } } A. B. C. D. Message passing copies more data. Message passing only works across a network. Message passing is a security risk. We usually do use message passing! Which of these conditions is easiest to give up to prevent deadlocks? A. Mutual exclusion (make everything sharable) B. Hold and wait (must get all resources at once) C. No preemption (resources can be taken away) D. Circular wait (total order on resource requests) E. I’m not willing to give up any of these! Given the following table, for which values of X, Y, and Z, is this a safe state in the Banker's Algorithm? Claim Allocation P1 P2 P3 P1 P2 P3 Availability R1 3 6 1 Y 4 1 Z 7 R2 2 2 X 2 1 1 1 5 A. B. C. D. X = 3, Y = 1, Z = 1 X = 2, Y = 0, Z = 2 Both of these are safe states Neither of these are safe states Total Which type of deadlock-handling scheme would you expect to see in a modern OS (Linux/Windows/OS X) ? A. Deadlock prevention B. Deadlock avoidance C. Deadlock detection/recovery D. Something else Which form of fragmentation is easiest for the OS to reduce/eliminate? A. Internal fragmentation B. External fragmentation C. Neither Which memory allocation algorithm leaves the smallest fragments (external)? A. first-fit B. worst-fit C. best-fit Where would worst-fit place this memory chunk? A. 5 MB B. 7 MB C. 9 MB 5 MB How would the buddy system allocate the following set of requests? Assume 8 MB free initially. Alloc 3 MB, Alloc 1.5 MB, Alloc 1 MB 8 MB 4 MB B. 4 MB 2 MB 8 MB 2 MB 8 MB 4 MB 1 MB 4 MB A. 1 MB 3 MB 5 MB C. 2.5M 2 MB 2.5M 2 MB 1.5M 1 MB Given what we currently know about memory, what must we do during a context switch? A. Allocate memory to the switching process B. Load the base and bound registers C. Convert logical to physical memory addresses Segment Address Translation Segment Table Index Valid Base Bound Perm 1 0 120 600 r 2 1 8000 1000 rw 3 1 9000 512 wx • Physical address of 2 1200 ? A. 8000 B. 9200 C. Error 20 5 bit segment address, 32 bit logical address, 1 GB Physical memory. How many entries will we have in our segment table? A. 32: The logical address size is 32 bits B. 32: The segment address is five bits C. 30: We need to address 1 GB of physical memory 21 Which of these would be true about a multi-level page table, compared to a single-level page table? A. Multi-level usually uses less memory. B. Multi-level usually has faster lookup times. C. Both cause the same amount of fragmentation. D. More than one of the above is true. 22 A page fault occurs. What must we do in response? A. Find the faulting page on disk. B. Evict a page from memory and write it to disk. C. Bring in the faulting page and retry the operation. D. Two of the above E. All of the above 23 Handing faults from disk seems very expensive. How can we get away with this in practice? A. We have lots of memory, and it isn’t usually full. B. We use special hardware to speed things up. C. We tend to use the same pages over and over. D. This is too expensive to do in practice! 24 Your closet is full, but you just got a new shirt. How do you make room for it in your closet? A. Throw out another shirt at random. B. Throw out your newest shirt. C. Throw out your oldest shirt. D. Throw out a shirt you haven’t worn for a while. E. I govern my closet with some other shirt replacement policy. 25 Which is true of the Clock algorithm? A. Clock will always have fewer faults than FIFO. B. Clock will always have the same fault count as LRU. C. Clock will always have more faults than Optimal. D. More than one of the above. E. None of the above. 26 Why are disks slow? A. We have to move a disk head. B. We have to spin the disk platters. C. Disk data is farther away from the CPU/Mem. D. More than one of these. E. All of these. 27 Regarding file types… A. The OS distinguishes between file types. B. The user distinguishes between file types. C. Both the OS and users distinguish between file types. D. Nobody distinguishes between file types, files are all just files. 28 Which of the following is commonly represented by a file? A. B. C. D. E. A mouse A link to another file A directory More than one of the above All of the above 29 A file’s “path” determines where it is stored on a disk device. A. True B. False C. Sometimes 30 Why do we have an open() call, as opposed to just read()ing or write()ing a file path? A. B. C. D. E. To check file permissions To improve performance To lookup the file’s location on disk Two of the above All of the above 31 For a memory mapped file… A. The entire file must be in memory. B. Pages are brought in as accessed. C. All pages will eventually be written back to disk. D. More than one of the above. 32 Which allocation strategy has the smallest space overhead? Easiest to resize a file? Answer Choice Smallest Overhead Easiest to Resize a File A Extents Extents B Non-contiguous Contiguous C Non-contiguous Extents D Contiguous Non-contiguous 33 Suppose a block is 1 KB (210 bytes). How many pointers do we need in our block map to support a maximum file size of 16 GB (234 bytes)? Block size: 1 KB … ? A: 210 B: 216 C: 224 E: Some other number of pointers D: 234 34 What about writes? What if we lose power, and our modified data is only in memory? When should we write it to the disk to maintain reliability? A. Write blocks to disk immediately, to ensure safety. B. Write blocks when we evict them from the cache, to maximize performance. C. Write blocks when the user explicitly tells us to, since the user/application knows best. D. Write blocks to disk at some other time. 35