1 / 35

Operating Systems Clicker Questions

Operating Systems Clicker Questions. Kevin Webb & Cynthia Taylor. The operating system kernel…. Executes as a process Is always executing, in support of other processes Should execute as little as possible More than one of the above. Why shouldn’t processes control context switching?.

Download Presentation

Operating Systems Clicker Questions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating SystemsClicker Questions Kevin Webb & Cynthia Taylor

  2. The operating system kernel… • Executes as a process • Is always executing, in support of other processes • Should execute as little as possible • More than one of the above

  3. Why shouldn’t processes control context switching? • It would cause too much overhead • They could refuse to give up the CPU • They don’t have enough information about other processes

  4. Which CPU scheduling policy is the best? • Processes keep CPU until done (maximize throughput) • Processes use a fraction of CPU and pass it on (ensure fairness) • Processes receive CPU in proportion to their priority or what they pay (prioritize importance) • Other (explain)

  5. Which is true of round-robin schedules relative to first-come first-served. • Round-robin requires knowledge of process run times. • Round-robin schedules have lower average turnaround times. • Round-robin schedules have higher average turnaround times. • Round-robin has higher overhead. • More than one of these

  6. Multi-level feedback queues will naturally prioritize… • Compute-bound processes • I/O-bound processes • Long-running processes • Short processes

  7. Which component of a process might we replicate to take advantage of multiple CPUs? • The address space (memory) • OS resources (open files, etc.) • Execution state (PC, SP, registers, etc.) • More than one of these • Some other component(s)

  8. 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?) • Kernel thread • User thread • Some other sort of thread

  9. For processes (or threads) to communicate, we must have: • a data transfer mechanism • a synchronization mechanism • either synchronization or data transfer • both synchronization and data transfer

  10. /* NO SHARED MEMORY */ Producer int item; while (TRUE) { item = Produce (); send (Consumer, &item); } Consumer int item; while (TRUE) { receive (Producer, &item); Consume (item); } Suppose we’re using message passing, will this code operate correctly? • No, there is a race condition. • No, we need to protect item. • Yes, this code is correct.

  11. /* NO SHARED MEMORY */ Producer int item; while (TRUE) { item = Produce (); send (Consumer, &item); } Consumer int item; while (TRUE) { receive (Producer, &item); Consume (item); } This code is correct and relatively simple. Why don’t we always just use message passing (vs semaphores)? • Message passing copies more data. • Message passing only works across a network. • Message passing is a security risk. • We usually do use message passing!

  12. Which of these conditions is easiest to give up to prevent deadlocks? • Mutual exclusion (make everything sharable) • Hold and wait (must get all resources at once) • No preemption (resources can be taken away) • Circular wait (total order on resource requests) • I’m not willing to give up any of these!

  13. Given the following table, for which values of X, Y, and Z, is this a safe state in the Banker's Algorithm? • X = 3, Y = 1, Z = 1 • X = 2, Y = 0, Z = 2 • Both of these are safe states • Neither of these are safe states

  14. Which type of deadlock-handling scheme would you expect to see in a modern OS (Linux/Windows/OS X) ? • Deadlock prevention • Deadlock avoidance • Deadlock detection/recovery • Something else

  15. Which form of fragmentation is easiest for the OS to reduce/eliminate? • Internal fragmentation • External fragmentation • Neither

  16. Which memory allocation algorithm leaves the smallest fragments (external)? • first-fit • worst-fit • best-fit

  17. Where would worst-fit place this memory chunk? 5 MB A. 5 MB 7 MB B. 9 MB C.

  18. How would the buddy system allocate the following set of requests? Assume 8 MB free initially. 8 MB 4 MB 4 MB Alloc 3 MB, Alloc 1.5 MB, Alloc 1 MB 2 MB 2 MB 8 MB 8 MB 3 MB 5 MB B. 4 MB 4 MB 2.5M 2.5M 2 MB 2 MB C. 1.5M 1 MB A. 1MB 1 MB

  19. Given what we currently know about memory, what must we do during a context switch? • Allocate memory to the switching process • Load the base and bound registers • Convert logical to physical memory addresses

  20. Segment Address Translation • Physical address of ? A. 8000 B. 9200 C. Error 2 1200

  21. 5 bit segment address, 32 bit logical address, 1 GB Physical memory.How many entries will we have in our segment table? • 32: The logical address size is 32 bits • 32: The segment address is five bits • 30: We need to address 1 GB of physical memory

  22. Which of these would be true about a multi-level page table, compared to a single-level page table? • Multi-level usually uses less memory. • Multi-level usually has faster lookup times. • Both cause the same amount of fragmentation. • More than one of the above is true.

  23. A page fault occurs. What must we do in response? • Find the faulting page on disk. • Evict a page from memory and write it to disk. • Bring in the faulting page and retry the operation. • Two of the above • All of the above

  24. Handing faults from disk seems very expensive. How can we get away with this in practice? • We have lots of memory, and it isn’t usually full. • We use special hardware to speed things up. • We tend to use the same pages over and over. • This is too expensive to do in practice!

  25. Your closet is full, but you just got a new shirt. How do you make room for it in your closet? • Throw out another shirt at random. • Throw out your newest shirt. • Throw out your oldest shirt. • Throw out a shirt you haven’t worn for a while. • I govern my closet with some other shirt replacement policy.

  26. Which is true of the Clock algorithm? • Clock will always have fewer faults than FIFO. • Clock will always have the same fault count as LRU. • Clock will always have more faults than Optimal. • More than one of the above. • None of the above.

  27. Why are disks slow? • We have to move a disk head. • We have to spin the disk platters. • Disk data is farther away from the CPU/Mem. • More than one of these. • All of these.

  28. Regarding file types… • The OS distinguishes between file types. • The user distinguishes between file types. • Both the OS and users distinguish between file types. • Nobody distinguishes between file types, files are all just files.

  29. Which of the following is commonly represented by a file? • A mouse • A link to another file • A directory • More than one of the above • All of the above

  30. A file’s “path” determines where it is stored on a disk device. • True • False • Sometimes

  31. Why do we have an open() call, as opposed to just read()ing orwrite()ing a file path? • To check file permissions • To improve performance • To lookup the file’s location on disk • Two of the above • All of the above

  32. For a memory mapped file… • The entire file must be in memory. • Pages are brought in as accessed. • All pages will eventually be written back to disk. • More than one of the above.

  33. Which allocation strategy has the smallest space overhead? Easiest to resize a file?

  34. 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)? A: 210 B: 216 C: 224 D: 234 E: Some other number of pointers Block size: 1 KB … ?

  35. 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? • Write blocks to disk immediately, to ensure safety. • Write blocks when we evict them from the cache, to maximize performance. • Write blocks when the user explicitly tells us to, since the user/application knows best. • Write blocks to disk at some other time.

More Related